Use different MOSI pins at once on T4.0?

Status
Not open for further replies.

Electric Potato

Well-known member
Hey guys,

I'm trying to resolve an old issue with using T3.2 + nrf24l01 + audioShield + SerialFlashRaw at the same time. Basically, when SerialFlashRaw is playing a sample, it causes the nrf to think it's receiving wireless packets. I know this is due to having the nrf's MOSI/SCK connected to pins 7/14, which it shares with both the W25Q128 chip and the SD card.

But I notice that on T4.0 there is a 3rd MOSI and a 3rd SCK (MOSI2/SCK2). Is it possible to set the nrf's MOSI/SCK to these pins so that it no longer shares with the SD card and flash chip? I was unsure since the only way I know of specifying the MOSI pin is just SPI.setMOSI(7) which doesn't help me in trying to specify a unique channel.

Thanks!
 
Hey guys,

I'm trying to resolve an old issue with using T3.2 + nrf24l01 + audioShield + SerialFlashRaw at the same time. Basically, when SerialFlashRaw is playing a sample, it causes the nrf to think it's receiving wireless packets. I know this is due to having the nrf's MOSI/SCK connected to pins 7/14, which it shares with both the W25Q128 chip and the SD card.

But I notice that on T4.0 there is a 3rd MOSI and a 3rd SCK (MOSI2/SCK2). Is it possible to set the nrf's MOSI/SCK to these pins so that it no longer shares with the SD card and flash chip? I was unsure since the only way I know of specifying the MOSI pin is just SPI.setMOSI(7) which doesn't help me in trying to specify a unique channel.

Thanks!

On the Teensy 3.2, there was only one SPI bus (using the SPI global variable), but you had alternate pins:
  • MOSI is normally pin 11, but you could use the alternate pin 7;
  • MISO is normally pin 12, but you could use the alternate pin 8;
  • SCK is normally pin 13, but you could use the alternate pin 14.

The typical reason you need to use the alternate pins is because you are using the Audio Shield. The I2S pins for MCLK and IN overlap with the SPI pins (MCLK on 3.2, 3.5, and 3.6 is pin 11, and IN is pin 13).

The Teensy 4.0 has 3 separate SPI buses, but it doesn't have any alternate pins. The I2S1 pins also got relocated on the Teensy 4.0.

The first SPI bus (using the SPI global variable) uses:
  • MOSI is pin 11;
  • MISO is pin 12;
  • SCK is pin 13.

The second SPI bus (using the SPI1 global variable) uses:
  • MOSI1 is solder pad 26;
  • MISO1 is pin 1 (note, the pinout card doesn't list this)
  • SCK1 is solder pad 27.

The third SPI bus (using the SPI2 global variable) uses:
  • MOSI2 is solder pad 34;
  • MISO2 is solder pad 35;
  • SCK2 is solder pad 37.

Because of the change of the I2S pins and no longer using the alternate SPI pins, you can't use audio shield revisions A-C (that use the 3.2, 3.5, and 3.6 SPI alternate pins) directly on a Teensy 4. You need to get the revision D audio shield that is made for the Teensy 4. And for nrf24l01, you would need to relocate the SPI pins back to 11-13.

But what it sounds like is you need to look at this paper, which outlines some problems (and possible solutions) when you have multiple items on the same SPI bus:

Alternatively, you would need to move the nrf24l01 to the second SPI bus. You probably need to clone the library, renaming it so it uses SPI1 instead of SPI. This will involve soldering 2 wires to the solder pads under the Teensy to bring out MOSI1 and SCK1, and use pin 1 for MISO1. Or bring out the third SPI bus, but note solder pads 34-39 are 1mm pitch instead of 2.54mm, so it is much harder to bring out the connection due to the smaller solder pad size.
 
Thanks for that great info! That clears up a lot. That article is extremely helpful too.
I don't have a T4 at the moment, but I added this to my sketch
Code:
#define nrf_spi_channel 1 //if using T3.2 comment this out to select the default SPI.

And then replaced '#define _SPI SPI' with this in 'RF24_arch_config.h':
Code:
  #if defined (nrf_spi_channel) //only for T3.5 and up only
	#if nrf_spi_channel == 1 
		#define _SPI SPI1
	#elif nrf_spi_channel == 2
		#define _SPI SPI2
	#endif
  #else
	#define _SPI SPI //default
  #endif

(Using the RF24 library)

Seems like it should do it but I can't give it a whirl yet.
 
Last edited:
Status
Not open for further replies.
Back
Top