Teensy 3.6 vs Arduino Issues with Adafruit Bluefruit LE SPI Friend

Status
Not open for further replies.
Powering Bluefruit with the 3v3 output on the Teensy. Everything is 3v3, nothing is going to a 5v signal.

Just got fresh new Teensy 3.6s in today and the same problem is happening - it was the first program I run on them and the issue persists. Might rule out a hardware fault?
 
Just tried it with a Teensy LC. Works perfectly fine with no changes to any software or hardware! Still looking for a solution for the Teensy 3.6 since I need that clock speed and SD card.
 
Another update: Teensy 3.6 with software SPI works with 4MHz setting with the same pins. Does this narrow down the problem to the hardware SPI library?

Since timing is critical for me and I can't waste clock cycles, I should avoid software SPI, right?
 
Just a blind guess, but is it possible this Bluefruit module also depends on short delays between commands? Maybe the AVR chips always pause several microseconds due to normal code execution speed, but Teensy 3.6 is able to run the code much faster and start another communication sooner.

We saw this sort of problem last year with a popular Lidar module. If you waited 20ms (as the default examples did), it always worked. But if you read its status register to detect when it was ready, so you could get the data as soon as possible, it turned out the Lidar had a bug where it wasn't really ready for a few more microseconds and reading it immediately after it said it was ready would return bad data. As I recall, that particular Lidar has another even worse bug where asking it to make another measurement immediately after reading the data (without the 20ms wait) would crash its internal processor. Adding a several microsecond delay solved the problem. My guess is they only ever tested with a slow chip like AVR doing the I2C commands, where delays of a dozen microseconds are common while the AVR code does things like print to Serial buffers.
 
Very interesting... I'll try adding some delays after every SPI transaction to see if it solved the problem. Thanks for the suggestion! Will let you know how it goes.
 
Very interesting... I'll try adding some delays after every SPI transaction to see if it solved the problem. Thanks for the suggestion! Will let you know how it goes.

I added a delay to CS disable macro in Adafruit_BluefruitLE_SPI.h and that allowed the example bleuart_datamode sketch to run OK on T3.2@120mhz. For T3.6@180mhz needed a delay in CS enable too.

#define SPI_CS_ENABLE() digitalWrite(m_cs_pin, LOW);delayMicroseconds(1)
#define SPI_CS_DISABLE() delayMicroseconds(1);digitalWrite(m_cs_pin, HIGH)


I tested a few other examples with the iPhone apps. (e.g. throughput test 3.9 KBs)

Using 1.8.3/1.37 with BLE https://www.adafruit.com/product/2633

EDIT: I didn't test a lot with different delays. It worked with 1 us delay, but not with two asm volatile ("nop"); No delay was required if T3.2 was running @72mhz or less.
 
Last edited:
I know it's an old subject, but I had the same issue about Adafruit Bluefruit LE SPI Friend :
It works well with an arduino nano, but didn't work with my Teensy 4.0

I added a delay to CS disable macro in Adafruit_BluefruitLE_SPI.h and that allowed the example bleuart_datamode sketch to run OK on T3.2@120mhz. For T3.6@180mhz needed a delay in CS enable too.

#define SPI_CS_ENABLE() digitalWrite(m_cs_pin, LOW);delayMicroseconds(1)
#define SPI_CS_DISABLE() delayMicroseconds(1);digitalWrite(m_cs_pin, HIGH)

I can confirm that when I added this in my Adafruit_BluefruitLE_SPI.h it now works on my Teensy 4.0 CPU Speed=600 Mhz.
Thank you for this manitou !
 
Status
Not open for further replies.
Back
Top