Page 1 of 2
compilation error
Posted: Thu Jan 23, 2025 8:30 am
by ChrisT66
Hi, when I try to compile with the macro ‘SetBaud’ I get this error (and other similar ones):
error: ‘UBRR1L’ undeclared (first use in this function)
What exactly does this mean?
Thanks and best regards Chris
Re: compilation error
Posted: Thu Jan 23, 2025 9:26 am
by LeighM
The macro has C code which has been written for a specific target device,
so won't work with a different device.
Re: compilation error
Posted: Thu Jan 23, 2025 9:38 am
by ChrisT66
Yes exactly, also for the ATMEGA328P that I use
Re: compilation error
Posted: Thu Jan 23, 2025 9:53 am
by medelec35
If you change the target device to one that does contain all the SFR's e.g. ATMEGA640 then the code will compile successfully.
Is there a reason for creating your own C code?
I would recommend if it's for learning, check register names within the microcontroller datasheet first.
ATMEGA328 only contains UBRR0H/L, all the other register e.g. UBRR1H/L etc are missing.
Hence reason for failing to compile.
Re: compilation error
Posted: Thu Jan 23, 2025 9:59 am
by ChrisT66
Unfortunately, the normal ‘ChangeHWBaude’ function for the UART does not work. There have already been posts about this here...
Re: compilation error
Posted: Thu Jan 23, 2025 10:04 am
by medelec35
ChrisT66 wrote: ↑Thu Jan 23, 2025 9:59 am
Unfortunately, the normal ‘ChangeHWBaude’ function for the UART does not work. There have already been posts about this here...
In that case, thank you for letting us know.
I will put it on my list to investigate, so you won't need to use C code.
If I replicate it not working, I will move the topic to Bugs.
Re: compilation error
Posted: Thu Jan 23, 2025 10:07 am
by ChrisT66
Ok, then I hope you find the error, thanks!
Re: compilation error
Posted: Thu Jan 23, 2025 12:59 pm
by medelec35
As you have not added 9 or 10 post icon, I will assume you are using FC10.
Just tested on the Uno and ChangeHWBaud is working as intended, toggling between 4800 and 19200 .
Analyser set for 2400 & sending U:

- ChangeHWBaud1.png (53.08 KiB) Viewed 1945 times
Do have an example .fcfx project where it is not working?
Re: compilation error
Posted: Thu Jan 23, 2025 1:55 pm
by ChrisT66
I have to generate a new project first, I can do that. I'm not using a UNO etc. but the chip direct, an ATMEGA328P and 328PB.
Re: compilation error
Posted: Thu Jan 23, 2025 2:03 pm
by ChrisT66
I have tested it again, I am transmitting from one module with 115200 baud to another. If I configure the UART of the receiver module with 9600 baud and then set it to 115200 with ChangeHWBaud after initialisation in the program, it does not work.