No Response on SPI from BlueNRG-MS. How do I know where the problem is ?
Hello everyone,
I've designed a PCB With a STM32H7 which is supposed to control a BlueNRG-MS. The design is the similar to the Figure 6 of the component datasheet: https://www.st.com/resource/en/datasheet/bluenrg-ms.pdf
I didn't put XTAL1 since it's optional. I also put a Balun instead of the impedence matching circuit (not related to the problem).
My PCB is ready and have all the component. My program is running on the STM32H7 as intended, except for the Bluetooth part.
I am using the X-CUBE-BLE1 BLE stack and sample applications for BlueNRG-MS module.
The init call returns succesfully and pull the RESET PIN of the BlueNRG-MS module High on my PCB.
hci_init(NULL, NULL);According to this document: https://www.st.com/resource/en/application_note/dm00116738-bringing-up-the-bluenrg-and-bluenrgms-devices-stmicroelectronics.pdf
under the Test procedure paragraph, there should be signals on MISO, IRQ and CS Pins , unless i'm wrong. On my PCB, CS and RESET are HIGH.
The 1V8 and 1V2 are OK and the 16MHz clock is ticking at 16MHz correctly.
Then, I try to run the following function:
aci_hal_write_config_data(CONFIG_DATA_PUBADDR_OFFSET, CONFIG_DATA_PUBADDR_LEN, BT_address)which return 255 (TIMEOUT).
I found that the error comes from this function:
/**
* @brief Writes data from local buffer to SPI.
*
* @param buffer : data buffer to be written
* @param size : size of first data buffer to be written
* @retval int32_t: Number of read bytes
*/
int32_t HCI_TL_SPI_Send(uint8_t* buffer, uint16_t size)
{
int32_t result;
uint8_t header_master[HEADER_SIZE] = {0x0a, 0x00, 0x00, 0x00, 0x00};
uint8_t header_slave[HEADER_SIZE];
static uint8_t read_char_buf[MAX_BUFFER_SIZE];
uint32_t tickstart = HAL_GetTick();
do
{
result = 0;
/* CS reset */
HAL_GPIO_WritePin(HCI_TL_SPI_CS_PORT, HCI_TL_SPI_CS_PIN, GPIO_PIN_RESET);
/* Read header */
BSP_SPI4_SendRecv(header_master, header_slave, HEADER_SIZE);
if(header_slave[0] == 0x02)
{
/* SPI is ready */
if(header_slave[1] >= size)
{
BSP_SPI4_SendRecv(buffer, read_char_buf, size);
}
else
{
/* Buffer is too small */
result = -2;
}
} else {
/* SPI is not ready */
result = -1;
}
/* Release CS line */
HAL_GPIO_WritePin(HCI_TL_SPI_CS_PORT, HCI_TL_SPI_CS_PIN, GPIO_PIN_SET);
if((HAL_GetTick() - tickstart) > TIMEOUT_DURATION)
{
result = -3;
break;
}
} while(result < 0);
return result;
}I can see the trame {0x0a, 0x00, 0x00, 0x00, 0x00} on the oscilloscope on MOSI and there is nothing on MISO. Which indicate that the SPI is not ready, then the function return a Timeout.
Figure 1. SPI_MOSI and SPI_CLK during (BSP_SPI4_SendRecv(header_master, header_slave, HEADER_SIZE);)
Figure 2. SPI_MOSI and SPI_CS during (BSP_SPI4_SendRecv(header_master, header_slave, HEADER_SIZE);)
Figure 3. XTAL2 after SPI_RESET goes HIGH.
According to the Test document, if there is no signal on IRQ after a reset, it means that the BlueNRG firmware is not running.
Here are some explanations possible to my problem:
- Is the firmware on the BlueNRG-MS when you buy it ?
- Should I have a XTAL1 for the firmware to run ?
- Something else hardware or software related ?
Thank you for any suggestions.
