user2548217
user2548217

Reputation: 11

pic18f14k50 not outputting

I'm using the pic 18f14k50 and I'm trying a simple test with it. Just make a LED blink. The thing is, I've already set ANSEL, ANSELH, ADCON1, etc, all to 0, also put all the PORTS as outputs. Still I haven't seen and LED blinking.

Here goes the code(I'm using 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
}

Thanks for all the help!

Upvotes: 1

Views: 236

Answers (1)

John b
John b

Reputation: 1398

Why won't this PIC code light up my LEDs?

"If you do not set the ANSEL register the pin cannot be used as output as it is configured as an analog input."

The config bits are not visible here. Your oscillator config bits must be correct for the processor to start the code.

The 18f14k50 can be difficult to program. It requires 3 volts on the PGC, and PGD pins, and the vpp is much less then the standard 13 volts. Are you using a programmer (pic kit 1,2,3, ICD 2,3) or a bootloader (HID Boot loader)?

Upvotes: 1

Related Questions