/*

    1/30/03
    Copyright Spark Fun Electronics 2003©
    
    Classic Blinking Test Routine for the 18 Pin PIC16F628

    Flashes all pins on PIC - 20MHz operations
    
*/

#include "d:\Pics\c\16F628.h"  // device dependent definitions

//#pragma config |= 0x3F10 //Internal RC Oscillator
//#pragma config |= 0x3F22 //HS Oscillator, MCLR Pin Enabled
#pragma config |= 0x3F02 //HS Oscillator, MCLR Pin used as General IO

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

    while(1)
    {
        PORTA = 0x00;
        PORTB = 0xFF;
        delay_ms(1000);
    
        PORTA = 0xFF;
        PORTB = 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++);
}