PIC18 TUTORIAL 1

All tutorial in this series are using MikroC pro from mikroelektronika. you can download free version of software for training purpose.

This is a simple 'Hello World' project. It turns on/off LEDs connected to 
PORTA, PORTB, you can connect all 8 LEDs to each port or just place one LED to each port for testing example.

MCU:             PIC18F45K22
http://ww1.microchip.com/downloads/en/DeviceDoc/41412D.pdf
Oscillator:      HS-PLL 32.0000 MHz, 8.0000 MHz Crystal
 
void main() {
  TRISA = 0;           // set direction to be output
  TRISB = 0;           // set direction to be output
  do {
    LATA = 0x00;       // Turn OFF LEDs on PORTA
    LATB = 0x00;       // Turn OFF LEDs on PORTB
    Delay_ms(500);    // 0.5 second delay
    LATA = 0xFF;       // Turn ON LEDs on PORTA
    LATB = 0xFF;       // Turn ON LEDs on PORTB
    Delay_ms(500);    // 0.5 second delay
  } while(1);          // Endless loop
}

No comments:

Post a Comment