STM32W108单通道如下设置就可以了
void ADCConfigura
tion(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
多看看例程
例程上面没有关于多通道的例子啊。。可否请大神指教下。。谢谢了
ADC_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.
button3state=1;
if(button3state!=((GPIO_PCIN&C0_MASK)>>C1_BIT))//PC1l连接一按键
{
beepload();
button3state=((GPIO_PCIN&C0_MASK)>>C1_BIT);
}
此程序貌似是直接读取按键的PCIN的输入值,而不用中断
实验现象应该是按键按下,蜂鸣器响
释放按键,蜂鸣器不响
但是实际却并未成功,就是不明白如何去读取GPIO_PCIN的返回引脚输入值
求大神赐教!!!!!!!!!!!!!!!!!!!!!!!!!!
大神貌似也在学习STM32W108,我最近也在学习,在某些问题上我们可以相互探讨qq:320959100
一周热门 更多>