哪位大神帮忙看下为啥这比较器程序用proteus仿真没结果
时间:10-02
整理:3721RD
点击:
我就是想简单测试下比较器的功能,脉冲设置的为-0.7-5V,但是比较器无输出,应该也没进入中断,求助。
#include <pic.h>
__CONFIG(FOSC_INTOSC&PWRTE_OFF&MCLRE_OFF&WDTE_OFF&CP_OFF&CPD_OFF&BOREN_ON&IESO_OFF&FCMEN_OFF&CLKOUTEN_OFF); //配置字1
__CONFIG(WRT_OFF&PLLEN_ON&STVREN_OFF&LVP_OFF); //配置字2
#define uchar unsigned char
#define delay_1us() asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
void init_io(void)
{
TRISC=0b001110;
LATC=0b010100;
TRISA=0b001010;
LATA=0b000000;
ANSELA=0x02;
ANSELC=0x00;
OSCCON=0xf0; // 78-16MHZ
}
void delay_130us()
{
unsigned int i,m;
for(i=0;i<1;i++)
{
for(m=0;m<78;m++);
}
}
void InitCMP()
{
CM1CON0=0b01110100;
CM1CON1=0b01110000;
PEIE=1;
GIE=1;
C1IE=1;
C1ON=1;
}
void interrupt CMP()
{
C1IF=0;
LATCbits.LATC0=1;
delay_130us();
LATCbits.LATC0=0;
delay_130us();
}
void main(void)
{
init_io(); // 初始化IO RC0
InitCMP();
while(1);
}
#include <pic.h>
__CONFIG(FOSC_INTOSC&PWRTE_OFF&MCLRE_OFF&WDTE_OFF&CP_OFF&CPD_OFF&BOREN_ON&IESO_OFF&FCMEN_OFF&CLKOUTEN_OFF); //配置字1
__CONFIG(WRT_OFF&PLLEN_ON&STVREN_OFF&LVP_OFF); //配置字2
#define uchar unsigned char
#define delay_1us() asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
void init_io(void)
{
TRISC=0b001110;
LATC=0b010100;
TRISA=0b001010;
LATA=0b000000;
ANSELA=0x02;
ANSELC=0x00;
OSCCON=0xf0; // 78-16MHZ
}
void delay_130us()
{
unsigned int i,m;
for(i=0;i<1;i++)
{
for(m=0;m<78;m++);
}
}
void InitCMP()
{
CM1CON0=0b01110100;
CM1CON1=0b01110000;
PEIE=1;
GIE=1;
C1IE=1;
C1ON=1;
}
void interrupt CMP()
{
C1IF=0;
LATCbits.LATC0=1;
delay_130us();
LATCbits.LATC0=0;
delay_130us();
}
void main(void)
{
init_io(); // 初始化IO RC0
InitCMP();
while(1);
}