本帖最后由 zhtbit 于 2018-11-13 14:44 编辑
使用STM32F405做SPI的从机发送,使用RTE_Device,假定和主机之间每次传输70个字节,正常条件下通信正常,但是如果主机某一次发送的字节数不为70(比如69或者71),从机判断出来帧数不等于70,想重新启动一下DMA接收和发送,保证下一帧主机发送的字节为正常的70时,通信能恢复正常;
现在的现象是,只要主机某一次发送的字计数不为70,后续从机给主机发送的数据全部都错位,即使重启了SPI也不行:
SPI_COMM_PORT.PowerControl(ARM_POWER_OFF);
SPI_COMM_PORT.Uninitialize();
我试着重启了DMA,也不行:
DMA1_Stream7->CR &= ~((uint32_t)DMA_SxCR_EN);
DMA1_Stream0->CR &= ~((uint32_t)DMA_SxCR_EN);
DMA1_Stream7->CR = 0;
DMA1_Stream0->CR = 0;
DMA1_Stream7->PAR = 0;
DMA1_Stream0->PAR = 0;
DMA1_Stream7->NDTR = 0;
DMA1_Stream0->NDTR = 0;
DMA1_Stream7->M0AR = 0;
DMA1_Stream0->M0AR = 0;
DMA1_Stream7->M1AR = 0;
DMA1_Stream0->M1AR = 0;
DMA1_Stream7->FCR = (uint32_t)0x00000021;
DMA1_Stream0->FCR = (uint32_t)0x00000021;
DMA1->LIFCR = (uint32_t)(DMA_LISR_FEIF0 | DMA_LISR_DMEIF0 |
DMA_LISR_TEIF0 | DMA_LISR_HTIF0 |
DMA_LISR_TCIF0);
DMA1->HIFCR = (uint32_t)(DMA_LISR_FEIF0 | DMA_LISR_DMEIF0 |
DMA_LISR_TEIF0 | DMA_LISR_HTIF0 |
DMA_LISR_TCIF0)<<22;
DMA1->HIFCR = DMA1->HIFCR| ((uint32_t)0x20000000);
跪求各位高手指点,是哪里配置不对么
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>