Show more

"hal_spi_dma_trans" hangs while doing SPI DMA transfer because it's waiting for a FreeRTOS Event Group ... Which is supposed to be signalled by the DMA Interrupt Handler. Let's comment out the waiting and see what happens...

github.com/lupyuen/bl_iot_sdk/

Show thread

Commented out the waiting for SPI DMA ... Yep no more hanging ... But no SPI Data received. Interrupt Counters show that DMA Interrupts weren't triggered.

The plot thickens ... Just like my chicken soup 🤔

github.com/lupyuen/bl_iot_sdk/

Show thread

Aha SPI DMA is now Transmitting AND Receiving! The SPI Mode was incorrect ... Got confused between the AliOS docs and the BL602 implementation 🙁

Received SPI Data is garbage though 🤔

github.com/lupyuen/bl_iot_sdk/

Show thread

@ThePine64 connected to BME280 and LA2016 Logic Analyser ... Let's sniff the SPI Bus and find out what's wrong!

Show thread

Let's try 2 SPI Transfers instead of 1 ... First SPI Transfer transmits Register ID ... Second SPI Transfer receives the result from BME280

github.com/lupyuen/bl_iot_sdk/

Show thread

LA2016 Logic Analyser comes in this beautiful inspirational box ... "Embedded Development Kit: Innovative concept, win-win cooperation"

Show thread

Thankfully SPI HAL lets us use GPIO to control the Chip Select Pin ... But we have already configured the pin for SPI Function ... Will this conflict with the GPIO Function? 🤔

github.com/lupyuen/bl_iot_sdk/

Show thread

Nope HAL can't control Chip Select Pin by ... Because it has already configured the pin for SPI Port earlier ... Let's control the pin ourselves 👋

github.com/lupyuen/bl_iot_sdk/

Show thread
Follow

... Now writing about the 4 fixes I made ... 1️⃣ SPI Data Pins are flipped 2️⃣ SPI Phase should be 1 (though it behaves like 0) 3️⃣ Doing SPI Chip Select ourselves 4️⃣ Pin 0 switches on WiFi LED. Thanks for bearing with this long thread on @PINE64 🙏

lupyuen.github.io/articles/spi

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.