4545 views|0 replies

3

Posts

0

Resources
The OP

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!

This post is from stm32/stm8

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

    EEWorld
    subscription
    account

    EEWorld
    service
    account

    Automotive
    development
    circle

    Robot
    development
    community

    Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
    快速回复 返回顶部 Return list