STM32FV103的芯片,麻烦大家有例子的贴一个
我也要。。
我都不知道该什么弄。不理解。串口每次只能收发一个数据,如何用DMA
下面是我的设置,发不出
u8 test[2]={6,9};
//-------------------DMA设置---------
DMA_Cmd(DMA_Channel4,DISABLE);
DMA_DeInit(DMA_Channel4); DMA_InitStructure.DMA_PeripheralBaseAddr=USART1_BASE+USART_Mode_Tx;
DMA_InitStructure.DMA_MemoryBaseAddr=(u32)test;
DMA_InitStructure.DMA_DIR = eripheralDST;
DMA_InitStructure.DMA_BufferSize = 2;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA_Channel4,&DMA_InitStructure);
DMA_Cmd(DMA_Channel4,ENABLE);
while(!DMA_GetFlagStatus(DMA_FLAG_TC4));
//--------------------------串口-------------------------------
USART_InitStructure.USART_BaudRate = 115200;//250000;
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_InitStructure.USART_Clock = USART_Clock_Disable;
USART_InitStructure.USART_CPOL = USART_CPOL_Low;
USART_InitStructure.USART_CPHA = USART_CPHA_2Edge;
USART_InitStructure.USART_LastBit = USART_LastBit_Disable;
USART_Init(USART1, &USART_InitStructure);
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
USART_DMACmd(USART1,USART_DMAReq_Tx, ENABLE);
USART_Cmd(USART1, ENABLE);
//---------------------开DMA时钟---------------------------
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA,ENABLE);
发不出去不用DMA就可以
你QQ多少:
我的是:253115201。。
szled加我。。
re:
1,USART_Mode_Tx是什么?外设地址应该是串口的发送寄存器,USARTx->DR
2,eripheralDST?发送时应该是内存到外设
3,外设和内存的数据宽度应该是字节,不是半字