CH32V103时钟中断里调用spi函数,一直停在spi函数while语句里,如何解决?
代码如下:
void TIM3_IRQHandler(void) //TIM3中断 10ms
{
short temp_data;
if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //检查指定的TIM中断发生与否:TIM 中断源
{
TIM_ClearITPendingBit(TIM3, TIM_IT_Update ); //清除TIMx的中断待处理位:TIM 中断源
if(++tim3_count>=100)
{
tim3_count=0;
tim3_flag=1;
if(level_time_flag) ++level_time_count;
}
adxdata=ADXL345_READ(0x36);
}
u8 ADXL345_READ(u8 add)
{
cs_low();
// delay_us(10);
SPI_I2S_SendData(SPI1,(add|0x80)<<8|0x00);
while(SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_TXE)==RESET);
while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE)==RESET);
//delay_us(10);
cs_high();
return SPI_I2S_ReceiveData(SPI1)&0xff;
}