本人使用STM32F334读写TM1628,也参考了网上一大堆的例子,查询发送数据到TM1628,发现大部分网上的例子都是用的是TXE 标志位 SPI_I2S_FLAG_TXE,要注意此标志位在手册上图片显示的是只要FIFO的数据移动到发发送缓冲器里面之后就会置位所以TXE的置位并不代表所有传输完成只代表可以接着发送数据,而是等到BSY置位后才表明发送结束,对于判断发送单个字节则需要结合BSY来判断,对于多个字节则是要结合TXE和BSY一起来使用是最好的。对于中断发送的话本人暂时还是没有好的方法毕竟BSY不能产生中断。总之感觉太不顺手
附上个人demo
uint8_t TM1628_WritePro(void)
{
if(0==TM1628_State)return 0;
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
SetSTB;
DelayXu(50);
ClrSTB;
SPI_SendData8(SPI1,0x00);
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET);
SetSTB;
DelayXu(50);
ClrSTB;
SPI1->DR = 0x44;
SPI_SendData8(SPI1,0x44);
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET);
SetSTB;
DelayXu(50);
ClrSTB;
SPI_SendData8(SPI1,0xC0);
SPI_SendData8(SPI1,TM1628_DATA[0]);
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET);
SetSTB;
DelayXu(50);
ClrSTB;
SPI_SendData8(SPI1,0xC2);
SPI_SendData8(SPI1,TM1628_DATA[1]);
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET);
SetSTB;
DelayXu(50);
ClrSTB;
SPI_SendData8(SPI1,0xC4);
DelayXu(20);
SPI_SendData8(SPI1,TM1628_DATA[2]);
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET);
SetSTB;
DelayXu(50);
ClrSTB;
SPI_SendData8(SPI1,0xC6);
SPI_SendData8(SPI1,TM1628_DATA[3]);
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET);
SetSTB;
DelayXu(50);
ClrSTB;
SPI_SendData8(SPI1,0x89);
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET);
SetSTB;
TM1628_State = 0 ;
return 0;
}