Tuesday, March 2, 2010

PORTA ?!

While trying to build my own electronic dice, I spent so long wondering why in the world can't my PORTA not work properly on my PIC16F887... n after a WHILE.... realised that I had to chage it to digital since portA is normally default as an analog pin...(and also forgot to disable my analog)

http://www.mikroe.com/forum/viewtopic.php?f=13&t=12981

void main() {
PORTA = 0; // Initialize PORTA
TRISA = 0; // Configure PORTA as output
ADCON1 = 6; // Changes PORTA to digital
CMCON = 7; // Disable analog comparators

while(1) {
PORTA = ~PORTA; // toggle PORTA
Delay_ms(1000); // one second delay
}
}

such a waste of time................. :(

No comments: