UART receive interrupt

Status
Not open for further replies.

raydee

Member
Hello everyone,

I just received my first Teensy 3.0 and am a bit exited right now ;) Guess you all know that feeling...
Now there are quite some questions evolving, which most boil down to read the 1k2++ pages of specs... guess I am spoilt by the vast arduino code base. Seems like everything code related has at least partly been done already in the arduino ecosystem.
Long story short, I am trying to port a sketch that uses ISR(USART_RX_vect) to receive data from a PC software. Its an LED matrix control software, that puts out it's own rather timing critical protocol (i.e. RGB values). So, is there an equivalent ISR available on ARM? Also, the macros for setting up the UART by flags seem to be missing:

Code:
UCSR0A |= (1<<U2X0);                                
UCSR0B |= (1<<RXEN0)  | (1<<TXEN0) | (1<<RXCIE0);   
UCSR0C |= (1<<UCSZ01) | (1<<UCSZ00)             ; 
UBRR0H = 0;
UBRR0L = 1;

Guess I'm back to that humungus PDF, if anyone can lend me a hand... would be really appreciated :)

Kind regards,
Ray
 
Teensy 3.0 has very different UART registers than AVR.

Probably the best place to start is hardware/teensy/cores/teensy3/serial1.c

It's also worth noting that Serial1 has 8 byte FIFOs, but Serial2 and Serial3 are an ordinary single byte buffer like AVR. If you need higher performance, the FIFOs are really nice, but they do add a little more complexity to the code. If you'd rather go with the simpler non-FIFO approach, best to look at serial2.c or serial3.c. One other tiny detail is serial3 is clocked by the bus clock, but serial1 and 2 are from the CPU clock, which is why there's 2 separate macros for baud rate to divisor in HardwareSerial.h.

If you'll post a link or info about this library, I'll put it on my list to investigate someday......
 
Thanks Paul for pointing me in the right direction. 1-byte Fifo is exactly what I need, I just have to find the right ISR vector that gets caught when there is a byte available.

It's not a library, but a sketch for the receiver side of a software that generates LED matrix animations: Glediator (java, needs native rxtx library for serial communication). Basically the software bangs out per pixel RGB values to COM that the sketch assembles and then offloads to the strip. I did a preliminary arduino adaption to WS2811 equipped 5050 RGB LEDs (aka WS2812)... here is a german thread and the original ws2801 sketch . I'll post the adapted sketch as soon as I reached showtime on Teensy3.
 
Hehe, I skipped the whole ISR stuff and just looped through Serial.available() with a 1mbit serial setup. Seems like Teensy3 has enough power to munch all that data without any special stricks, at least for the tiny matrix I have set up here...
 
Status
Not open for further replies.
Back
Top