STM32 frequent interrupts cause SPI to work abnormally, looking for help
[Copy link]
Hello, everyone!
I use STM32 SPI to control an RF device. It works fine without other serial ports, system ticks, or timer interrupts. However, when the system tick interrupt is enabled, STM32 often goes into a dead loop.
void NTRXReadSPI(MyByte8T address, MyByte8T *buffer, MyByte8T len) { // SysTick_ITConfig(DISABLE); if (len > 0x80 || len == 0) return;
nano_SPI_FLASH_CS_LOW();
/* Loop while DR register in not emplty */ while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET); /* Send byte through the SPI2 peripheral */ SPI_I2S_SendData(SPI2, (len & 0x7F));
/* Loop while DR register in not emplty */ while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET); /* Send byte through the SPI2 peripheral */ SPI_I2S_SendData(SPI2, address);
*buffer = SPI_I2S_ReceiveData(SPI2); / /clearRXEN
while(len-- > 0) { while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET); SPI_I2S_SendData(SPI2, 0xff);
while( SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET ); *buffer++ = SPI_I2S_ReceiveData(SPI2);
} nano_SPI_FLASH_CS_HIGH(); // SysTick_ITConfig(ENABLE); }
In red font, I turned off the system tick function.
After a while, I needed to use the serial port function and the serial port receive interrupt. When receiving a small amount of data, there would be no problem. When receiving a large amount of data, that is, a large number of frequent interrupts, the above problems would occur again. Could you guys give me some advice?
Thank you!
|