cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX (5.2.1.) + X-CUBE-BLE1 (4.4.0) code generated SensorDemoBLESensor failes to init properly.

KnarfB
Principal III

I generate the code for my B-L475E-IOT01A board. That board works well, e.g. with HeartRate sample from STM32Cube_FW_L4_V1.14.0. But, I want to generate BLE code using STM32CubeMX. I choose my board type, check Wireless BlueNRG-MS and Wireless Application under Additional Software. I choose SensorDemoBLESensor, HCI_TL Basic and HCI_TL_INTERFACE User Board and generate the code for SW4STM32.

When I build, I get errors compiling b_l475e_iot01a_bus.c because of undefined symbols INTERNAL_SPI3_..._Pin, so I manually include main.h. (Why is this needed?)

Now, build completes, but the debugger gets stuck forever during SPI reset:

Thread #1 (Suspended : Signal : SIGINT:Interrupt)   

   SPI_EndRxTxTransaction() at stm32l4xx_hal_spi.c:3.941 0x80027d0   

   HAL_SPI_TransmitReceive() at stm32l4xx_hal_spi.c:1.475 0x8002b62   

   BSP_SPI3_SendRecv() at b_l475e_iot01a_bus.c:192 0x8004a2e   

   HCI_TL_SPI_Receive() at hci_tl_interface.c:123 0x80050ba   

   hci_notify_asynch_evt() at hci_tl.c:359 0x8003e94   

   hci_tl_lowlevel_isr() at hci_tl_interface.c:282 0x80051f6   

   HAL_EXTI_IRQHandler() at stm32l4xx_hal_exti.c:528 0x8000ec4   

   EXTI9_5_IRQHandler() at stm32l4xx_it.c:209 0x8005b6a   

   <signal handler called>() at 0xfffffff9   

   HAL_Delay() at stm32l4xx_hal.c:405 0x8000c4a   

   HCI_TL_SPI_Reset() at hci_tl_interface.c:98 0x800507a   

   hci_init() at hci_tl.c:178 0x8003ca8   

   MX_BlueNRG_MS_Init() at app_x-cube-ble1.c:131 0x8004854   

   main() at main.c:111 0x80056fe   

Any ideas what went wrong and how to recover? Are there working eamples, tutorials?

1 REPLY 1
KnarfB
Principal III

I found my error: SPI3 is initialized, but, despite all the magic, the initialization values are not usesful for talking to the BLE module. I changed it to Data Size 8 Bits and Baud Rate 5 MBit/s and now it works.

Some minor things are still open: in SensorDemo, the user button is not functional.