I got a simple loop-back SPI program to work.  I connected MISO to MISO with a jumper and then checked to see that the characters I sent out on MOSI matched the ones I got back on MISO.

It appears to be important to to set the slave select high before configuring it as an output or it creates glitches.

MISO is configured with no pullup.

The Nordic has two SPI channels which can be pointed at any set of GPIOs.

p_nrf_spi->PSELSCK  = p_spi_master_config->SPI_Pin_SCK;
p_nrf_spi->PSELMOSI = p_spi_master_config->SPI_Pin_MOSI;
p_nrf_spi->PSELMISO = p_spi_master_config->SPI_Pin_MISO;

I initialised the code to run with:

POL=ActiveHigh; 
PHA=Leading;
FREQ=125Kb;
BITORDER=MsbFirst

This is right for BusPirate SPI_Sniffer, but the bits are back-to-front on the scope

My program sets up to catch interrupts, and the interrupt handler simply sets a flag when the IO has finished.  The main loop

Here’s some output.

0: Hello SPI! => Hello SPI!
1: Hello SPI! => Hello SPI!
2: Hello SPI! => Hello SPI!
3: Hello SPI! => Hello SPI!
4: Hello SPI! => Hello SPI!
5: Hello SPI! => Hello SPI!
6: Hello SPI! => Hello SPI!
7: Hello SPI! => Hello SPI!
8: Hello SPI! => Hello SPI!
9: Hello SPI! => Hel

If the jumper is not in place then the SPI hardware clocks character 255 into the receive buffer.

0: Hello SPI! => ÿÿÿÿÿÿÿÿÿÿ
1: Hello SPI! => ÿÿÿÿÿÿÿÿÿÿ
2: Hello SPI! => ÿÿÿÿÿÿÿÿÿÿ
3: Hello SPI! => ÿÿÿÿÿÿÿÿÿÿ
4: Hello SPI! => ÿÿÿÿÿÿÿÿÿÿ
5: Hello SPI! => ÿÿÿÿÿÿÿÿÿÿ
6: Hello SPI! => ÿÿÿÿÿÿÿÿÿÿ
7: Hello SPI! => ÿÿÿÿÿÿÿÿÿÿ
8: Hello SPI! => ÿÿÿÿÿÿÿÿÿÿ
9: Hello SPI! => ÿÿÿÿÿÿÿÿ

Using the Bus Pirate and SPI_Sniffer

The startup bat file contain this:

SPIsniffer -d COM4 -r 0 -s 125000
pause

The data is interpreted as follows:

BP_record ::= CS_low ‘[‘ { DataPair } CS_hi ‘]’ 

CS_low    ::= 0x5B
CS_hi     ::= 0x5D
DataPair  ::= MOSI ‘(‘ MISO ‘)’
 

MOSI      ::= .dec .hex
MISO      ::= .dec .hex

SPI working on TS06.2

I connected Noridc pin20 to pin22 to create the SPI loopback.
It worked right away!  Yay.
Discovered that the LED on pin0 is not working.

Leave a Reply