在STM32社区里下载了一个“uC/OS-II官方STM32版本修改后在万利的STM32开发板上运行”的工程程序,连接目标板后编译、加载、运行都正常的,我将串口发送改为DMA传输,编译后运行,程序停止在了下面的这行: App_Fault_ISR B App_Fault_ISR 产生了Hard Fault异常,请问这是怎么回事?
下面是初始化程序部分: USART_InitStructure.USART_BaudRate = UART1_BAND; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No ; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure); USART_Cmd(USART1, ENABLE);
USART_DMACmd(USART1, USART_DMAReq_Tx, ENABLE);
DMA_UART1Tx_StructInit(); DMA_Init(DMA1_Channel4, &DMA_UART1TxStructure); DMA_ITConfig(DMA1_Channel4, DMA_IT_TC, ENABLE);
BSP_IntVectSet(BSP_INT_ID_DMA1_CH4, DMA1_CH4_Uart1TxFinish); BSP_IntPrioSet(BSP_INT_ID_DMA1_CH4, DMA1_CH4_UART1Tx_UIP); BSP_IntEn(BSP_INT_ID_DMA1_CH4);
下面是DMA1_Channel4中断处理程序 void DMA1_CH4_Uart1TxFinish(void) { DMA_ClearITPendingBit(DMA1_IT_TC1); Uart1_Data.TxStatus = READY; }
下面是发送子程序 void UART1SendData(COMM_Q *pQdata) { u32 temp; COMM_Q_char TxBuf[UART_TxBufSize];
temp = Uart1QTx->QEntries; if (Uart1QTx->QEntries != 0) { if (COMM_QPopStr(Uart1QTx, TxBuf, 0)== COMM_Q_OK) { DMA_Cmd(DMA1_Channel4, DISABLE); DMA_UART1TxStructure.DMA_MemoryBaseAddr = (u32)TxBuf; DMA_UART1TxStructure.DMA_BufferSize = temp; DMA_Init(DMA1_Channel4, &DMA_UART1TxStructure); DMA_Cmd(DMA1_Channel4, ENABLE); } } }
类型 COMM_Q_char 定义 unsigned char
|