-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
#include <util/delay.h>
int main(void) {
uart0_init(BAUD_CALC(9600UL));
while (1) {
uart0_putint(1023);
uart0_puts("\r\n");
_delay_ms(1000);
}
}Using -Os -std=gnu99 to compile.
cat /dev/ttyUSB0 | xxd
00000000: 3130 3233 08f5 0a0a 3130 3233 08f5 0a0a 1023....1023....
00000010: 3130 3233 08f5 0a0a 3130 3233 08f5 0a0a 1023....1023....
00000020: 3130 3233 08f5 0a0a 3130 3233 08f5 0a0a 1023....1023....
Original uart0_putint function from the library (comment added):
void uart0_putint(int16_t data)
{
#ifndef USART_NO_LOCAL_BUFFERS
char u_tmp_buff[7]; // heading, 5 digit bytes, NULL
#endif
itoa(data, u_tmp_buff, 10);
uart0_putstr(u_tmp_buff);
// asm volatile("nop");
}Adding the nop command fixes this bug.
asm volatile("nop");$ cat /dev/ttyUSB0 | xxd
00000000: 3130 3233 0a0a 3130 3233 0a0a 3130 3233 1023..1023..1023
00000010: 0a0a 3130 3233 0a0a 3130 3233 0a0a 3130 ..1023..1023..10
I don't think anyone will review this. In case someone does: I can provide concrete compile commands and more details.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels