2

This code is used for communication between the Glediator interface and a NeoPixel Matrix, but I receive an error saying 'UCSR0A' is not defined within the scope.

UCSR0A |= (1<<U2X0);                                
UCSR0B |= (1<<RXEN0)  | (1<<TXEN0) | (1<<RXCIE0);   
UCSR0C |= (1<<UCSZ01) | (1<<UCSZ00)             ; 
UBRR0H = 0;
UBRR0L = 1; //Baud Rate 1 MBit (at F_CPU = 16MHz)

Any feedback is appreciated.

3 Answers 3

1

Those register names are for a different chip (maybe the ATMega328P of the Uno).

Instead you need to use the right register names. Start by reading the datasheet for the ATMega32U4. You might find that the register names are UCSR1A etc, or UCSRA or something like that instead of UCSR0A.

0
0

You should be able to use Serial1 to access the USART. But...

Note that on the Yún, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class. The hardware serials of the ATmega32U4 and the AR9331 on the Yún are connected together and are used to communicate between the two processors. As is common in Linux systems, on the serial port of the AR9331 is exposed the console for access to the system, this means that you can access to the programs and tools offered by Linux from your sketch[1].

Please see below references for further details:

  1. https://www.arduino.cc/en/Main/ArduinoBoardYun
  2. https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/variants/yun/pins_arduino.h#L40
  3. https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/variants/leonardo/pins_arduino.h#L363
1
  • Thanks Mikael, I think you just helped me find the problem with the serial communication. I am trying to communicate with an interface called Glediator which is a program that controls LED's of matrices. I have an 16x16 matrix connected to the Yun and It works when upload a sketch to it from ADI itself, but for Glediator i have to upload a Communication Interface script but I think something is edited wrong. As soon as I Open Serial in Glediator, the program freezes. Would you have the time to look at my code, I posted it on this page underneath your comment. Thank you in advance! Jan 9, 2016 at 22:02
0

So what I did was changing the codes by replacing the '0' from the other chipset to the '1' on the Atmega32u4

UCSR1A |= (1<<U2X1);                                
UCSR1B |= (1<<RXEN1)  | (1<<TXEN1) | (1<<RXCIE1);   
UCSR1C |= (1<<UCSZ11) | (1<<UCSZ10)             ; 
UBRR1H = 0;
UBRR1L = 1; //Baud Rate 1 MBit (at F_CPU = 16MHz)

ISR(USART_RX_vect) 
{
  unsigned char b;
  b=UDR1;
...

I think that this is the problem that causes freeze when I Open Serial. Any advice? Thanks In advance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.