avrdudes / avr-libc

The AVR-LibC package provides a subset of the standard C library for AVR 8-bit RISC microcontrollers.
https://avrdudes.github.io/avr-libc/
Other
218 stars 50 forks source link

[bug #57299] util/setbaud.h incompatible with new AVR iom*.h headers #673

Open avrs-admin opened 2 years ago

avrs-admin commented 2 years ago

Mon 25 Nov 2019 07:10:21 PM CET

Newer headers povided in the device packs from microchip include a struct for UARTS that defines a member "BAUD".   This conflicts with the use of command line argument "-DBAUD-9600U".   Use of this command line argument to avr-gcc results in compile error:

/opt/local/bin/avr-gcc -mmcu=atmega4809 -DF_CPU=3333333UL -Os -I.. -I../../ -B/opt/local/avr/packs/mega-1.3.300 -DBAUD=9600UL -c main.c -o main.o In file included from /opt/local/avr/include/avr/io.h:578, from main.c:3:

: error: expected identifier or '(' before numeric constant A solution is to not include util/setbaud.h and instead use command line argument -DBAUDRATE=9600UL with the following usage: USART0.BAUD = BAUDRATE; There is a workable solution but the problem of running into the obscure error message will persist.  Maybe replacing BAUD with some other convention will help. This issue was migrated from https://savannah.nongnu.org/bugs/?57299
avrs-admin commented 2 years ago

Joerg Wunsch Mon 25 Nov 2019 08:06:30 PM CET

Well, it's really a poor idea from the to use such a common name like BAUD for a subregister. I wonder how much code needs to be reworked now ...

Sure, we could work around that by calling it BAUDRATE, and make BAUD an alias for it on controllers where it does not conflict.

avrs-admin commented 2 years ago

Matt Wette Mon 25 Nov 2019 10:03:48 PM CET

My proposed workaround is not correct because one still needs to compute the baud rate with respect to the F_CPU, so we still need a way to compute the register value.