|
还是不启动
按照参考手册和例程程序的顺序都试了,还是不能启动传输。
初始化程序: GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure;
/* Configure USARTx_Tx as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIOA_Tx1Pin; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USARTx_Rx as input floating */ GPIO_InitStructure.GPIO_Pin = GPIOA_Rx1Pin; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure);
DMA_UART1Tx_StructInit(); DMA_Init(DMA1_Channel4, &DMA_UART1TxStructure);
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);
/* USARTx configuration ------------------------------------------------------*/ /* USARTx configured as follow: - BaudRate = 115200 baud - Word Length = 8 Bits - One Stop Bit - No parity - Hardware flow control disabled (RTS and CTS signals) - Receive and transmit enabled */ USART_InitStructure.USART_BaudRate = 115200; 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_DMACmd(USART1, USART_DMAReq_Tx, ENABLE);
发送子程序: 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); USART_Cmd(USART1, ENABLE);
这样还是不行,运行后没有数据从串口发出去。 |
|