此帖出自微控制器 MCU论坛
最新回复
请教一个TSM320F28027比较器的问题,代码如下,测试时通过电位器调整comp1A,COMP1B的输出输入电压,COMP1OUT输出没变化,GPIO38也没有变化,请问程序中哪里有问题啊?
void Comp1Test(void)
{
EALLOW;
GpioCtrlRegs.GPBPUD.bit.GPIO38 = 0; //enable the internal pullup
GpioCtrlRegs.GPBMUX1.bit.GPIO38 = 0; //I/O
GpioCtrlRegs.GPBDIR.bit.GPIO38 = 1; //output
GpioCtrlRegs.GPAPUD.bit.GPIO1 = 1; // Disable pull-up for GPIO1 (CMP1OUT)
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 3; // Configure GPIO1 for CMP1OUT operation
GpioCtrlRegs.GPADIR.bit.GPIO1 = 1; //output
GpioCtrlRegs.AIOMUX1.bit.AIO2 = 3; //AIO2 disabled --- COMP1A
GpioCtrlRegs.AIOMUX1.bit.AIO10 = 3; //AIO10 disabled --- COMP1B
SysCtrlRegs.PCLKCR3.bit.COMP1ENCLK = 1;
SysCtrlRegs.PCLKCR3.bit.COMP2ENCLK = 1;
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;//the ADC module is clocked
AdcRegs.ADCCTL1.bit.ADCPWDN = 1; //The analog circuitry inside the core is powered up
AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; //Bandgap buffer's curcuitry inside core is powered up
Comp1Regs.COMPCTL.bit.COMPDACEN = 1; //comparator/DAC logic is powered up
Comp1Regs.COMPCTL.bit.COMPSOURCE = 1; //inverting input connected to exteranl pin
Comp1Regs.COMPCTL.bit.SYNCSEL = 0; //asynchronous
Comp1Regs.COMPCTL.bit.QUALSEL = 0; //Synchronized value of comparator is passed through
Comp1Regs.COMPCTL.bit.CMPINV = 1; //Output of comparator is passed
EDIS;
for(;;)
{
if(Comp1Regs.COMPSTS.bit.COMPSTS==1)
{
GpioDataRegs.GPBDAT.bit.GPIO38 = 1;
}
else
{
GpioDataRegs.GPBDAT.bit.GPIO38 = 0;
}
}
}
详情
回复
发表于 2014-11-27 08:55
| ||
|
||
此帖出自微控制器 MCU论坛
| ||
|
||
浏览过的版块 |
EEWorld Datasheet 技术支持