TeensyLC / Teensy3.2: wrong SPI reads

jym

New member
Hi,

I've a strange issue with a TeensyLC and a RFM95 (SX1276 Chip from Semtech):

When I read on the SPI bus, data returned by SPI.transfer() are different from data on the bus (I checked with a logic analyzer). In fact, the first bytes are good but after some read, data are not correct (I have ~48 bytes to read, more than half are bad). The SPI slave chip (SX1276) sends correct data and my SPI.transfer() doesn't return the same data.

My function is very simple:

Code:
    SPI.beginTransaction(SPISets);
    digitalWrite(nss, LOW);
    SPI.transfer(addr & 0x7F);
    for (uint8_t i = 0; i < size; i++) {
        buffer[i] = SPI.transfer(0x00);
    }
    SPI.endTransaction();
    digitalWrite(nss, HIGH);

My hardware is very simple too: just a teensy with a RFM95. SPI wire are short (< 1 inch).

I tried with Teensy3.2, and with different clock speed for clock or SPI bus (from 1Mhz to 12Mhz). Changing the clock speed change the number of 'good' read. But problem doesn't disappear.

Adding a noInterrupts() / interrupts() around this function and a display of the buffer in between, that doesn't help (so the problem doesn't come from a messy interrupt).

If I add a slow function in the 'for()' loop (a Serial.print(), for example), all reads are good... So, I suspect a clock problem. But how to debug ?

Thanks for your help :)

Best,
jym
 
Back
Top