/*

    10-14-03
    Copyright Spark Fun Electronics 2003©
    
    Classic Blinking Test Routine for the 40 Pin PIC18F452
    
    Flashes all pins on PIC - 20MHz operations

*/

#include "d:\Pics\c\cc8e\18F452.h"  // Device dependent definitions

#pragma config[1] = 0b.0010.0010 //HS Oscillator
#pragma config[2] = 0b.0000.0000 //Brown out off, PWRT On
#pragma config[3] = 0b.0000.0000 //WDT Off
#pragma config[6] = 0b.1000.0000 //ICD Off, LVP Off, Stack Overflow Reset off

void delay_ms(uns16);

void main()
{
    PORTA = 0b.0000.0000;
    TRISA = 0b.0000.0000;  //0 = Output, 1 = Input

    PORTB = 0b.0000.0000;
    TRISB = 0b.0000.0000;  //0 = Output, 1 = Input

    PORTC = 0b.0000.0000;
    TRISC = 0b.0000.0000;  //0 = Output, 1 = Input

    PORTD = 0b.0000.0000;
    TRISD = 0b.0000.0000;  //0 = Output, 1 = Input

    PORTE = 0b.0000.0000;
    TRISE = 0b.0000.0000;  //0 = Output, 1 = Input


    //Turn Port A to Digital Outputs
    ADCON1 = 0b.0000.0111;

    while(1)
    {

        PORTA = 0xFF;
        PORTB = 0xFF;
        PORTC = 0xFF;
        PORTD = 0xFF;
        PORTE = 0xFF;
        delay_ms(1000);

        PORTA = 0x00;
        PORTB = 0x00;
        PORTC = 0x00;
        PORTD = 0x00;
        PORTE = 0x00;
        delay_ms(1000);
    }

}

//General short delay
void delay_ms(uns16 x)
{
    uns8 y, z;
    for ( ; x > 0 ; x--)
        for ( y = 0 ; y < 4 ; y++)
            for ( z = 0 ; z < 176 ; z++);
}
