cancel
Showing results for 
Search instead for 
Did you mean: 

SPI is always stuck in busy state

RBair.3
Associate II

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);
    }
}

3 REPLIES 3
Bob S
Principal

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".

TDK
Guru

> __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.

If you feel a post has answered your question, please click "Accept as Solution".
RBair.3
Associate II

Thanks everyone. I figured it out. It turns out that radio->hspi was not being initialized correctly. Thanks for the help.