Let's hunt for MEPC (Machine Exception Program Counter) 0x2300 8fe2 in the #RISCV Disassembly ... Yep my buggy code crashed in the #BL602 I2C Interrupt Handler 🤔
https://github.com/lupyuen/bl_iot_sdk/releases/download/v1.0.1/sdk_app_i2c.S
Found the bug in my #BL602 I2C program ... There are two levels of BL602 I2C API: 1️⃣ High Level (which calls FreeRTOS) 2️⃣ Low Level (which doesn't call FreeRTOS) ... I'm using the Low Level API, so I shouldn't call "hal_i2c_init" in the High Level API
https://github.com/lupyuen/bl_iot_sdk/blob/i2c/customer_app/sdk_app_i2c/sdk_app_i2c/main.c#L187-L190
When the #BL602 I2C HAL looks dubious ... Refer to the BL602 Reference Manual!
https://github.com/bouffalolab/bl_docs/tree/main/BL602_RM/en
Testing BME280 I2C Sensor with Bus Pirate ... While figuring out why it doesn't respond to #BL602 🤔
Shall I use Bus Pirate to sniff the I2C Bus on #BL602? 🤔
http://dangerousprototypes.com/docs/I2C#I2C_Bus_Sniffer_macro
Oops I need to Write To MEN (heh heh) after setting the #BL602 I2C Registers ... Lemme Write To MEN now
https://github.com/bouffalolab/bl_docs/tree/main/BL602_RM/en
#BL602 #I2C still no go after writing to MEN ... Let's hook on to the I2C Interrupts and observe what happens
https://github.com/bouffalolab/bl_docs/tree/main/BL602_RM/en
Here's our simple #BL602 I2C Interrupt Handler ... When we hit an I2C Interrupt, bump up the Interrupt Counters ... Remember: No funny business allowed in Interrupt Handlers (like Console Output)
https://github.com/lupyuen/bl_iot_sdk/blob/i2c/customer_app/sdk_app_i2c/sdk_app_i2c/demo.c#L226-L251
After counting the #BL602 I2C Interrupts ... We now see 2 I2C problems: No Acknowledge and FIFO Error 🤔
https://github.com/lupyuen/bl_iot_sdk/blob/i2c/customer_app/sdk_app_i2c/sdk_app_i2c/demo.c#L216
Mind getting muddled over #BL602 #I2C Transactions ... Here's the Note to Self
https://github.com/lupyuen/bl_iot_sdk/blob/i2c/customer_app/sdk_app_i2c/sdk_app_i2c/demo.c#L442
#BL602 I2C "Slave Address" vs "Device Address" vs "Slave Device Address" vs "Slave Device Register Address" ... A little confusing 🤔
https://github.com/bouffalolab/bl_docs/tree/main/BL602_RM/en
#PineCone #BL602 I2C finally works OK ... Reads BME280 Chip ID correctly yay!
https://github.com/lupyuen/bl_iot_sdk/blob/i2c/customer_app/sdk_app_i2c/sdk_app_i2c/demo.c#L215-L490
#BL602 I2C program doesn't crash now ... But it doesn't read any data from the BME280 Sensor 🤔
https://github.com/lupyuen/bl_iot_sdk/blob/i2c/customer_app/sdk_app_i2c/sdk_app_i2c/demo.c#L216-L308