Skip to main content
PFuen.1
Associate
September 17, 2020
Question

X-NUCLEO-BNRG2A1 stuck on reset using X-CUBE-BLE2

  • September 17, 2020
  • 8 replies
  • 4192 views

Hi, recently I got a X-NUCLEO-BNRG2A1 and I am trying to use it with NUCLEO-G070RB without success. I have created a project with STM32CubeMx assistance using SampleApp of X-CUBE-BLE2, mapping the pins of the expansion board to my nucleo board as follows:

RST - PA8

SPI_SCK - PA5

SPI_MOSI - PA7

SPI_MISO - PA6

CS - PA1

SPI_EXTI_IRQ - PA0

The project successfully built and uploaded into the MCU, however the application does not do anything it just stuck in the function HCI_TL_SPI_Reset. I have already tried installing the DTM hex file into X-NUCLEO-BNRG2A1, however it does not solve the problem.

is it a problem of the DTM software?

8 replies

VMach.1
Associate II
September 22, 2020

Hi @PFuen.1​ did you manage to solve this issue?

PFuen.1
PFuen.1Author
Associate
September 22, 2020

Hi,

No, I didn't. It seems like the SPI_EXTI_IRQ never exits.

PD. I saw this answer after having seen your actual question :grinning_face_with_sweat: . I am still looking for answers but I haven't had any success.

VMach.1
Associate II
September 23, 2020

Hi,

yeah...I don't know why is so hard to find support on this.

SPI_EXTI_IRQ never exits? But when exactly does this happen?

I got stuck in hci_reset(), when it performs the CS reset the BlueNRG-2 seems not to be ready.

in file hci_tl_interface.c

 /* CS reset */
 HAL_GPIO_WritePin(HCI_TL_SPI_CS_PORT, HCI_TL_SPI_CS_PIN, GPIO_PIN_RESET);
 
 /*
 * Wait until BlueNRG-2 is ready.
 * When ready it will raise the IRQ pin.
 */

Do you also get stuck here or somewhere else?

-Víctor

PFuen.1
PFuen.1Author
Associate
September 23, 2020

Hi, yes I got stuck there too. However, it is because of the interrupt, when we release the reset pin of the BlueNRG-2, the module should start to generate interrupts, but it does not exit never (because there is no data available ?). I tried this code in hci_tl_lowlevel_isr:

volatile uint32_t cnt = 0;
// HCI Transport Layer Low Level Interrupt Service Routine
void hci_tl_lowlevel_isr(void) {
 cnt = 0;
 // Call hci_notify_asynch_evt()
 while (IsDataAvailable() && cnt < 100) {
 hci_notify_asynch_evt(NULL);
 cnt++;
 }
}

And you can see, that now you haven't got stuck in reset, but obviously, this will lead to errors in the initialization. Also if you don't connect the interrupt pin, you haven't got stuck, so I think that probably the problem is there. Hmm, maybe the interrupt pin is receiving at first time an undesired voltage that triggers the interrupt service, and as consequence there is no data available and loops, in that case we could add a pull resistor, but I am not sure.

VMach.1
Associate II
September 23, 2020

The interrupt is enabled in the NVIC interrupt table, right?

VMach.1
Associate II
September 23, 2020

Also, I found this thread https://community.st.com/s/question/0D50X00009XkeEaSAJ/firmware-update

where they say the very first time the FW needs to be updated.

I've been using the X-NUCLEO-BRNG2A1 + NUCLEO-L476RG without flashing any FW.

PFuen.1
PFuen.1Author
Associate
September 23, 2020

That's no the solution, 'cause I have flashed the FW again, but unfortunately that not solve the problem :downcast_face_with_sweat:

satyam9896
Associate III
December 21, 2022

hi @PFuen.1​ did you resolved the issue? if yes can you help me out with the same. I too not able to even initiate the bnrg2a1, its getting stuck in one of the while loop after getting gatt init failed, bdarr failed.

PFuen.1
PFuen.1Author
Associate
December 21, 2022

@satyam9896​ hi, yes I did, however I don't remember exactly what it was.

- You should check if "hci_tl_lowlevel_isr" is called in the external pin interrupt.

- SPI MUST have this configuration:

ClockPhase: LL_SPI_PHASE_2EDGE

ClockPolarity: LL_SPI_POLARITY_LOW

Note that LL_SPI_PHASE_2EDGE and LL_SPI_POLARITY_LOW belongs to the LL driver, but you can find the equivalent for the HAL library easily as they should have a similar name.

satyam9896
Associate III
December 21, 2022

I'm attaching the ss for simpler changes which you said . i just wanted to know regarding hci_tl_lowlevel_isr that it is correct ay to call ?0693W00000WLX1gQAH.png

satyam9896
Associate III
December 21, 2022

0693W00000WLX20QAH.png

satyam9896
Associate III
December 21, 2022

still im getting same errors.0693W00000WLX6wQAH.png

Visitor II
September 20, 2024

The ideas here were very useful! They took care of a lot of the issues I was having, but I still had a couple more issues. For the benefit of others, I will list them here:

  • Make sure all your SPI settings are correct! Refer to the Central.ioc file in the example project on github if you are adding the Central demo to your own project (I had the stm32WL55 nucleo, not the standard L-series Nucleo, but I was still able to use the Central sample application using CubeMX) 
    • SPI Data size defaults to 4, needs to be 8 (SPI_DATASIZE_8BIT)
    • Adjust the prescaler according to your CPU speed so that the baud rate is 2 > x >= 1mbps. I have 48 MHz, so SPI_BAUDRATEPRESCALER_32 gave 1.5 mbps, which works great! using prescaler of 16 did not!
  • I set EXTI pin to pulldown, so it couldn't accidentally be left high and cause spamming of interrupts
  • In GPIO section, click NVIC tab, and enable EXTI Line x Interrupt (where x is the pin number that EXTI pin is connected to on your board. On the L-series nucleo, it seems to be PA0, on mine it was PB1, so I selected EXTI Line 1 Interrupt). This creates and enables the appropriate callbacks that others have manually added.
  • Set ble RESET and CS gpio output pins default to High 

Good luck!