STM32W108 ADC多通道问题!!
STM32W108单通道如下设置就可以了void ADCConfiguration(void){
// 将GPIOA的引脚5定义为模拟输入
halGpioConfig(PORTA_PIN(5), GPIOCFG_ANALOG);
ADC_CFG = 0;
ADC_OFFSET = 0;
ADC_GAIN = 0x8000;
ADC_DMACFG = ADC_DMARST;
ADC_DMACFG = (ADC_DMAAUTOWRAP | ADC_DMALOAD);
ADC_DMABEG = (int32u)&adcData;
ADC_DMASIZE = 1;
// DMA缓冲区满中断使能
INT_ADCCFG = INT_ADCULDFULL;
// 清除所有中断标志
INT_ADCFLAG = 0xFFFF;
// 使能ADC全局中断
INT_CFGSET = INT_ADC;
ADC_CFG = (// 采样时间:1024 clocks,有效位:10 bits
(5
RE:STM32W108 ADC多通道问题!!
多看看例程:D回复:STM32W108 ADC多通道问题!!
回复第 2 楼 于2013-07-19 21:50:37发表:多看看例程:D
例程上面没有关于多通道的例子啊。。可否请大神指教下。。谢谢了
回复:STM32W108 ADC多通道问题!!
请大神们来帮帮忙啊回复:STM32W108 ADC多通道问题!!
4.Write the desired offset and gain correction values to the ADC_OFFSETR andADC_GAINR registers.
5.Start the ADC and the DMA.
Write the desired conversion configuration, with the ADC_EN bit set, to ADC_CR.
Clear the ADC buffer full flag – write DMABF to ADC_ISR.
Start the DMA in auto wrap mode – set the AUTOWRAP and LOAD bits in
ADC_DMACR.
6.Wait until the DMABF bit is set in ADC_ISR, then read the result from analogData.
To convert multiple inputs using this approach, repeat Steps 4 through 6, loading the desired
input configurations to ADC_CR in Step 5. If the inputs can use the same offset/gain
correction, just repeat Steps 5 and 6.
回复:STM32W108 ADC多通道问题!!
在这里,第5步是关键,就是设置ADC_CR的CHSELP及CHSELN位,它告诉了你要设置的通道号,如ADC1或ADC2等。设置好通道号后,等待DMABF位置位,就可以读到不同通道的ADC值。之后重复第5步,第6步完成不同通道的读取。回复:STM32W108 ADC多通道问题!!
STM32W108,怎么去读GPIO_PXIN返回引脚的输入值button3state=1;
if(button3state!=((GPIO_PCIN&PC0_MASK)>>PC1_BIT))//PC1l连接一按键
{
beepload();
button3state=((GPIO_PCIN&PC0_MASK)>>PC1_BIT);
}
此程序貌似是直接读取按键的PCIN的输入值,而不用中断
实验现象应该是按键按下,蜂鸣器响
释放按键,蜂鸣器不响
但是实际却并未成功,就是不明白如何去读取GPIO_PCIN的返回引脚输入值
求大神赐教!!!!!!!!!!!!!!!!!!!!!!!!!!
大神貌似也在学习STM32W108,我最近也在学习,在某些问题上我们可以相互探讨qq:320959100
页:
[1]