SPI Reference Example does not work

I am trying to read in data from a 8-byte shift register. It consistently reads all zeros.
I am referencing this example: https://developer.electricimp.com/api/hardware/spi/readblob

I had my SPI connected to an FPGA but I removed the FPGA and instead just connected a wire from 3V3 to pinB on my imp006. No other hardware connected to pinB

    // Configure the SPI bus on an imp006
spi <- hardware.spiXABCD;
spi.configure(SIMPLEX_RX | MSB_FIRST | CLOCK_IDLE_LOW, 400);

function read8bytes() {

    // Read some data...
    local s = spi.readblob(8);

    // ...and return it
    return s;                       

// Log results from the above functions

Expected output: something non zero
Actual output:

2020-08-07 20:31:27-0700 [Status] Downloading new code; 0.26% program storage used
2020-08-07 20:31:27-0700 [Device] binary: 00 00 00 00 00 00 00 00

After looking at the pin Mux, I realized that “spiXABCD” does not mean “SPI XA, B, C, D”, it means “SPI XA, XB, XC, XD”

I take it this is working now? Yes, we named peripherals on the Xx (or Yx on impC001) to be grouped with other pins in the same set for clarity.

Maybe we should note this more explicitly on the pin mux pages though.

Yes. My SPI is working now that I am using the correct pins.

This topic was automatically closed after 60 days. New replies are no longer allowed.