showing float in usart1 mikroc pro avr

Here you can find latest news on mikroElektronika products.
Post Reply
Author
Message
gsim
Posts: 5
Joined: 19 Aug 2015 13:14
Location: china

showing float in usart1 mikroc pro avr

#1 Post by gsim » 28 Aug 2015 18:48

thank you very much for replying Aleksandar.Mitrovic :
the compiler mikroc pro for avr and mcu atmega16 .
sorry i forget to mention that.

gsim
Posts: 5
Joined: 19 Aug 2015 13:14
Location: china

Re: showing float in usart1 mikroc pro avr

#2 Post by gsim » 21 Sep 2015 09:52

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

User avatar
aleksa.jovanovic
Posts: 526
Joined: 30 Jun 2015 08:48

Re: showing float in usart1 mikroc pro avr

#3 Post by aleksa.jovanovic » 23 Sep 2015 15:59

Hi,

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

Best regards,
ALeksa

Post Reply

Return to “Product Announcements”