brtaylor
Well-known member
I'm trying to transfer data very quickly between 2 Teensy 3.6's. I'm trying to use SPI, since that should be the fastest method. I'm using the following config for my SPI master Teensy 3.6:
* CS: 10
* MOSI: 11
* MISO: 12
* SCK: 13
I'm using the following config for my SPI slave Teensy 3.6:
* CS: 2
* MOSI: 11
* MISO: 12
* SCK: 14
This is my master code:
And my slave code:
I took gratuitously from this thread: https://forum.pjrc.com/threads/48749-I2C-SPI-ESP-webSockets-controller-for-teensy
My issues is that I would expect to see the slave print the number 10. Instead, I'm seeing 65535. Hoping that someone here will see my mistake.
Cheers!
Brian
* CS: 10
* MOSI: 11
* MISO: 12
* SCK: 13
I'm using the following config for my SPI slave Teensy 3.6:
* CS: 2
* MOSI: 11
* MISO: 12
* SCK: 14
This is my master code:
Code:
#include "SPI.h"
void setup()
{
Serial.begin(115200);
delay(5000);
pinMode(10, OUTPUT);
SPI.begin();
SPI.beginTransaction(SPISettings(24000000, MSBFIRST, SPI_MODE0));
digitalWriteFast(10, LOW);
SPI.transfer16(10);
digitalWriteFast(10, HIGH);
SPI.endTransaction();
}
void loop()
{
}
And my slave code:
Code:
#include "SPI.h"
void spi0_isr(void) {
Serial.println(SPI0_POPR);
SPI0_SR |= SPI_SR_RFDF;
}
void setup()
{
Serial.begin(115200);
SIM_SCGC6 |= SIM_SCGC6_SPI0; // enable slave clock
SPI0_MCR |= SPI_MCR_HALT | SPI_MCR_MDIS; // stop
SPI0_CTAR0_SLAVE = SPI_CTAR_FMSZ(15) & SPI0_CTAR0_SLAVE & (~(SPI_CTAR_CPOL | SPI_CTAR_CPHA) | 0x00 << 25);
SPI0_RSER = 0x00020000;
CORE_PIN14_CONFIG = PORT_PCR_MUX(2);
CORE_PIN11_CONFIG = PORT_PCR_DSE | PORT_PCR_MUX(2);
CORE_PIN12_CONFIG = PORT_PCR_MUX(2);
CORE_PIN2_CONFIG = PORT_PCR_PS | PORT_PCR_MUX(2); // this uses pin 2 for the CS so Serial2 can be used instead.
SPI0_MCR &= ~SPI_MCR_HALT & ~SPI_MCR_MDIS; // start
NVIC_ENABLE_IRQ(IRQ_SPI0); // enable CS IRQ
}
void loop()
{
}
I took gratuitously from this thread: https://forum.pjrc.com/threads/48749-I2C-SPI-ESP-webSockets-controller-for-teensy
My issues is that I would expect to see the slave print the number 10. Instead, I'm seeing 65535. Hoping that someone here will see my mistake.
Cheers!
Brian