第一个问题: 使用dma读取ADC1的转换结果,循环读取,读到规定的个数后就关闭了adc1,再需要读时,重新设置dma,后再开启adc1。出现的问题是:重新设置dma后必须延时一段时间再开adc1才能正常读取,否则就永远读不到了。
重设置dma:
DMA_Cmd(DMA1_Channel1, DISABLE);
DMA1_Channel1->CNDTR = count;
DMA_ClearITPendingBit(DMA1_IT_GL1);
DMA_Cmd(DMA1_Channel1, ENABLE);
重开adc:
ADC_Cmd(ADC1, ENABLE); //ADC1上电
ADC_ResetCalibration(ADC1);
while(ADC_GetResetCalibrationStatus(ADC1));
ADC_StartCalibration(ADC1);
while(ADC_GetCalibrationStatus(ADC1));
ADC_Cmd(ADC1, ENABLE); //使能ADC1
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
第二个问题:usart3部分重定位到pc10,pc11,接收和发送数据都不对,比如发0x55到串口监视工具,收到的DB,FD.
串口3的设置:
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_BaudRate = 19200;
USART_Init(USART3, &USART_InitStructure);
USART_Cmd(USART3, ENABLE);
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); USART_ClearFlag(USART3, USART_FLAG_TC); |