2701 views|1 replies

95

Posts

2

Resources
The OP
 

STM32SPI interrupt can only accept the first two bytes each time [Copy link]

The host SPI sends a group of numbers, such as A[]={"123456"}; the
slave SPI receives it using interrupts, and each data can be completely sent out, but the interrupt can only receive 12, and the other data cannot be received. Beginners need answers. The
host SPI sending function is as follows
/******
void SPI_Send_char(SPI_TypeDef* SPIx,uint16_t ch)
Send a character function
******/
void SPI_Send_char(SPI_TypeDef* SPIx,uint32_t ch)
{
if(SPIx==SPI1)
{
SPI_I2S_SendData(SPI1,ch);
while(SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_TXE)!=SET);
}
if(SPIx==SPI2)
{
SPI_I2S_SendData(SPI2,ch);

}
if(SPIx==SPI3)
{
SPI_I2S_SendData(SPI3,ch);
while(SPI_I2S_GetFlagStatus(SPI3,SPI_I2S_FLAG_TXE)!=SET);
}

}

/****
SPI_SendString(SPI_TypeDef* SPIx, uint32_t *String)
Send character string function
******/
void SPI_SendString(SPI_TypeDef* SPIx, int8_t *String)
{
while(*String)
{
SPI_Send_char(SPIx,*String);
String++;
}
}
/*****
SPI_SendString_Lenth(SPI_TypeDef* SPIx, uint32_t *String,uint16_t len)
Send a string of a certain length
*******/
void SPI_SendString_Lenth(SPI_TypeDef* SPIx, int8_t *String,uint16_t len)
{
uint16_t i=0;
for(i=0;i<len;i++)
{
SPI1_End_Reindex%=SPI1_Buf_Lenth;
SPI_Send_char(SPIx,*(String+SPI1_End_Reindex));
}
}


Slave SPI interrupt acceptance function
void SPI1_IRQHandler()
{
if(SPI_I2S_GetITStatus(SPI1,SPI_I2S_IT_RXNE) !=RESET)
{
SPI1_Start_Reindex%=SP I1_Buf_Lenth;
SPI1_Buf[SPI1_Start_Reindex]=SPI_I2S_ReceiveData(SPI1);
SPI1_Start_Reindex++;

}
//if(SPI_I2S_GetITStatus(SPI1,SPI_I2S_IT_TXE)!=RESET)
//{
// SPI_SendString_Lenth(SPI1,SPI1_Buf,SPI1_Re cieve_Lenth);
// SPI_I2S_ITConfig(SPI1,SPI_I2S_IT_TXE,DISABLE); //SPI transmit interrupt disabled
//}
}

This post is from stm32/stm8

Latest reply

Your interrupt sending conflicts with while(SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_TXE)!=SET);.   Details Published on 2019-6-14 16:23
 

4005

Posts

0

Resources
2
 

Your interrupt sending conflicts with while(SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_TXE)!=SET);.

This post is from stm32/stm8
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

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