Use this section to discuss your embedded Flowcode projects.
mnfisher
Valued Contributor
Posts: 2028 http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 160 times
Been thanked: 948 times
Post
by mnfisher » Wed Jun 03, 2026 9:18 pm
I mentioned that UART doesn't compile in hardware mode.
Looking at the CAL file - I wasn't sure why:
Code: Select all
#ifndef MX_XMEGA // It's not an XMEGA
#ifndef UDR0 // Not defined - compilation fails
#ifdef UDR
#define UDR0 UDR // UDR is defined...
As a 'crude' fix I added before this block:
#define UDR0 UDR
And the code compiles (and runs) correctly - I did the usual "hello world" and this is correctly sent.
I'm not sure why the current CAL code doesn't work though - and my 'fix' will surely break things for other AVR MCUs?
Martin
mnfisher
Valued Contributor
Posts: 2028 Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 160 times
Been thanked: 948 times
Post
by mnfisher » Wed Jun 03, 2026 10:04 pm
Looking at the fcdx files - an XMEGA device has:
</device>
<inline>
<defines code="#define MX_XMEGA\n\n#include <stdlib.h>\n#include <stdio.h>\n#include <math.h>\n#include <avr\io.h>\n#include <avr\interrupt.h>\n#include <avr\eeprom.h>\n#include <avr\wdt.h>\n\n" />
Whereas the ATTINY has:
</device>
<inline>
<defines code="#define MX_USI\n\n#define MX_UART_UCSRC\n\n#include <stdlib.h>\n#include <stdio.h>\n#include <math.h>\n#include <avr\io.h>\n#include <avr\interrupt.h>\n#include <avr\eeprom.h>\n#include <avr\wdt.h>\n\n" />
Should this define MX_ATTINY (or somesuch?)
But - doesn't explain why the #ifndef MX_XMEGA doesn't set a value for UDR0
Martin
BenR
Matrix Staff
Posts: 2214 Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 608 times
Been thanked: 804 times
Post
by BenR » Thu Jun 04, 2026 9:55 am
Thanks Martin, I'll see if I can make any headway on this. As you say strange it isn't just working? Also very glad you have a workaround for now.
The XMEGA have a totally different way of doing things to the other AVR devices which is why they have their own define. The ATMEGA and ATTINY are both fairly similar. The MX_USI define declares a certain type of UART and I'll start by checking this define is correct.