Hi. I would like to ask question related to USART in low-level. I am working with Arduino Uno and did all setup configurations; however, I am not able to print float data on serial monitor, it prints question marks. When I use "Serial.println" it works fine, so I do not have problems with setup. I could not find where is the problem. Could anyone, please, help me? Here is the code:
Thank you for your answer. I am trying to make USART in register level programming, I do not want to use Serial.println(float), but want to make my own print function
UDR0 is 1 byte and float is 4 bytes, it is the matter of size, thank you. However, I tried this code and it worked for int but does not for float again I got question marks
void transmit(unsigned char data){
while ( !( UCSR0A & (1<<UDRE0)) );
UDR0 = data;
}
void print_ln(const char* str)
{
int length = strlen(str);
int i;
for (i = 0; i < length; i++) {
transmit(str[i]);
}
}
This has nothing to do with the "low level" drivers, which handle essentially only "chars", and your initial messages attempting to put floats (or even ints) directly into uart registers were very wrong. Formatting/converting various data types for printing (printf/sprintf/etc) and actually sending the resulting characters to the USART are two different tasks.