I have been trying to display floating point value using printf function using serial port of ATmega8 but instead of displaying floating point value, '?' character is displayed. The output is
Float: ?
Here is the code
#include <stdio.h>
#include <float.h>
#include <avr/io.h>
int printCHAR(char character, FILE *stream)
{
while(!(UCSRA&0x20));
UDR=data;
return 0;
}
FILE uart_str = FDEV_SETUP_STREAM(printCHAR, NULL, _FDEV_SETUP_RW);
int main(void)
{
float fl = 1.3;
stdout = &uart_str;
UCSRB=0x18; // RXEN=1, TXEN=1
UCSRC=0x06; // no parit, 1-bit stop, 8-bit data
UBRRH=0;
UBRRL=71; //9600 baud rate
while(1)
{
printf("\r\nFloat: %f",fl);
}
}