Page 1 of 1

showing float in usart1 mikroc pro avr

Posted: 28 Aug 2015 18:48
by gsim
thank you very much for replying Aleksandar.Mitrovic :
the compiler mikroc pro for avr and mcu atmega16 .
sorry i forget to mention that.

Re: showing float in usart1 mikroc pro avr

Posted: 21 Sep 2015 09:52
by gsim
hi every one :
for more than three days i failed to solve this problem my problem is how to make this divition 1 or 2 /255 and show the result in usart all the times the result was wrong please help my. thanx in advance.
this my cod .

float per;
char per_txt[15] ;

void main(){
UART1_Init(9600);
per=(float)1/(float) 255;
floattostr(per,per_txt);
//UART1_Write_text(per_txt); //the result was w.215682e-4 allways is wrong sometimes h or g with number
sprintf(per_txt, "%12f",per); //also i used this and the result was -0.963375
UART1_Write_text(per_txt) ;

}

this my question but i found the answer that i am using proteus for simulation and proteus is not compatible with mikroc pro for avr compiler when i run it in real time there is no problem

Re: showing float in usart1 mikroc pro avr

Posted: 23 Sep 2015 15:59
by aleksa.jovanovic
Hi,

I've tried uploading this example to PIC18F45K22 and it outputs the correct value on the USART terminal.

Best regards,
ALeksa