2022-11-09 11:18 PM
I have found several other forum posts on this subject, and I've tried to follow them, but I'm still stuck. For some reason, SPI3 on my bl47eio1a never enters a ready state. It gets stuck waiting for a ready state before it ever can send or receive anything. Below is the code I'm using to try and force the SPI to reset. I got these tips from other forum posts, but I'm still stuck. I've also attached my .ioc file so you can try to reproduce the issue if desired.
void radioInit(const Radio *radio) {
__HAL_RCC_SPI3_FORCE_RESET();
__HAL_RCC_SPI3_RELEASE_RESET();
// wait for SPI to enter ready state
while(radio->hspi->State != HAL_SPI_STATE_READY) {
HAL_GPIO_TogglePin(radio->nss.port, radio->nss.pin);
HAL_Delay(100);
}
}
2022-11-10 07:19 AM
What do you do with the SPI port before you call that function? Is this SPI port configured as master or slave? Are you using the hardware NSS function?
hspi->State is a SOFTWARE (HAL layer) state. The FORCE_RESET() and RELEASE_RESET() macros are HARDWARE functions. Resetting the hardware (probably) has no effect on the software state. You need to find out why the software state is something other than "ready".
2022-11-10 07:37 AM
> __HAL_RCC_SPI3_FORCE_RESET();
> __HAL_RCC_SPI3_RELEASE_RESET();
> while(radio->hspi->State != HAL_SPI_STATE_READY) {
This is guaranteed not to work. HAL_SPI_DeInit should be called if you're using HAL functions. Calling __HAL_RCC_SPI3_FORCE_RESET will reset the registers but do nothing with the software state machine.
2022-11-10 09:55 AM
Thanks everyone. I figured it out. It turns out that radio->hspi was not being initialized correctly. Thanks for the help.