我正在使用 pic 18f14k50,我正在尝试使用它进行简单测试。只需让 LED 闪烁即可。问题是,我已经将 ANSEL、ANSELH、ADCON1 等全部设置为 0,还将所有端口都设置为输出。我还没有看到 LED 闪烁。
这是代码(我正在使用MicroC)
void main() {
TRISA = 0; // set direction to be output
TRISB = 0; // set direction to be output
TRISC = 0; // set direction to be output
ANSEL = 0;
ANSELH = 0;
IOCA = 0;
IOCB = 0;
CM2CON0.C2ON = 0;
CM1CON0.C1ON = 0;
ADCON1 = 0;
//PORTC = 0xFF;
while(1){
LATA = 0x00; // Turn OFF LEDs on PORTA
LATB = 0x00; // Turn OFF LEDs on PORTB
LATC = 0x00; // Turn OFF LEDs on PORTC
delay_ms(1000); // 1 second delay
LATA = 0xFF; // Turn ON LEDs on PORTA
LATB = 0xFF; // Turn ON LEDs on PORTB
LATC = 0xFF; // Turn ON LEDs on PORTC
delay_ms(1000); // 1 second delay
} // Endless loop
}
感谢所有的帮助!