Having trouble understanding serial processing basics

Apa102

Member
So I understand how conditionals work using typical UART serial data transfer. In arduino if serial.available is true and if serial.read returns some value that matches some variable then an action is performed and thats good, but I don’t like the slow baud rate of UART

So I’m using SPI, but what I’m not understanding is how do I transfer the data as a slave device from the SPDR register and send it for processing WITHIN the slave MCU and apply my conditional parameters like I would if I was using UART? I understand that SPI is a serial communication protocol, but the spi.begin object seems to be reserved for UART.

I don’t need to send my data back to the master, I just want to wait for 8 bits to load into my SPDR register, then move/import/send those bits not out of MISO, but to some buffer where I’ll be able to apply my conditional statements and use the data to perform some action like I would in uart, I’d like to be able to do something like

if (Serial.available() >0){

if (Serial.read() == 'x'){
// perform some action
}
else{

But instead of serial.read it would be reading 8 bits that came in through the spi ports.

Thanks in advance
 
What Teensy? T_4.x's can run at 2 Mbps or faster depending on the unit on both ends.

See pjrc.com/teensy/td_uart.html and page down to "Usable Baud Rates"

PaulStoffregen made this post: UART Serial may be more competitive with SPI than you're assuming

Also for Teensy to Teensy there is this library noted here pjrc.com/threads/66389-SPISlave_T4


The SPI Master/Slave library by @tonton81 is VERY effective and fabulous for great error checked throughput. But UART Serial is quick and reliable using fewer wires and less potential headache - and the UART code runs in the background filling a buffer with some interrupts but no direct attention until the bytes are read on Rx end and just pushed to a Tx buffer on the other.
 
Back
Top