USART - Register adapting from another controller

Hey folks,

I want to use this library DMXSerial2 with my Nano Every but I have troubles configure the USART-Register. Here are the variables of the previous controller:

#define UCSRnA UCSR0A  // Control and Status Register A
#define TXCn   TXC0
#define UCSRnB UCSR0B  // USART Control and Status Register B
#define RXCIEn RXCIE0  // Enable Receive Complete Interrupt
#define TXCIEn TXCIE0  // Enable Transmission Complete Interrupt
#define UDRIEn UDRIE0  // Enable Data Register Empty Interrupt
#define RXENn  RXEN0   // Enable Receiving
#define TXENn  TXEN0   // Enable Sending

But as I looked at the "USART-Register Summary" from the ATmega4809, I saw, that STATUS and CTRLA (Control A) are two different registers. Does anybody know, in which way I have to configure the register variables, so that the library works on my nano every?

kr, X-Berger.

1 Like

if the library works through registers, then you will have to rewrite the entire code, not just the configuration

2 Likes

The peripheral registers in the newer AVR chips (including the ATmega4809 used on the Every) are handled significantly differently than in the older AVRs. They're all treated as structs rather than individual registers, AND the USART itself has changed (for example, there are now separate transmit and receive data registers, and the baud rate generator is significantly different.
image

As @b707 says, you'll need a pretty complete re-write of the code. (well, probably only the USART initialization and ISRs. The DMX parsing looks to be pretty modular.)

2 Likes

Thank you @b707 and @westfw for your replies. You assured me in what I was expecting. I just wanted to be sure that there is no easy option I might have missed :grin: I have to consider using another chip so that we can utilize the original library, as we have a very tight schedule for this project. If we still decide to go with the ATmega4809, I would post a link to the solution here.

kr, X-Berger.

I'm willing to take a shot at modifying the code, if you're willing and able to do the testing.
I don't actually have any DMX equipment...

1 Like

I hope that does not apply to the testing you are going to be doing!

Very nice. If there's anything I can assist with, just let me know. Besides testing and providing feedback, that is definitely my task.

I already have an alternative, so testing is completely decoupled from the tight schedule :smile: I integrated an UNO R3, which was lying around, and it worked just fine.
Now, I have a solid test setup with:
1x ESP32 DMX-Controller,
1x ESP32 DMX-Device with RDM Response,
1x UNO R3 DMX-Device with RDM Response and
1x NANO EVERY which should do the same as the UNO R3.

This allows me to thoroughly test the new DMXSerial2 implementation.
kr, X-Berger.

It seems to me that this whole topic arose precisely because these boards are completely different

Yes, that's the topic of this thread :smile:
But with both "types" of µController as devices in the same bus, we can test the functionality of the modified library.

Hmm. Is there particular feature of this library (DMXSerial2) that you need? (RDM?)
It looks like DMXSerial - Arduino Reference has already been updated to support the Mega-0 chips used in the Nano Every.

Yes exact, I would like to use the RDM-feature of DMXSerial2 which is not supported in DMXSerial(1).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.