ArtemisGoldfish
Member
Okay, just to get myself back into having fun with PIC's, I wrote a little program to just make PORTA's bits turn on and off with a delay.
The delay/cyc loop just sticks 16 in general register 0x20 and loops back to provide a delay for the rest of the loop, which just uses a COMF to (One would hope) invert all the bits in PORTA. But, it doesn't, which leads me to (correctly) assume that I've done something wrong.
In Proteus, it won't even do anything, and in Oshonsoft's PIC Simulator, it first turns all of PORTA on at the first iteration of the loop, but then only inverts one of the bits thereafter on each iteration. Could someone tell me what I did wrong? The code is simple, and seems solid...Maybe I'm just not using COMF correctly?
Code:
#include P16F876A.INC
main BSF STATUS,5
MOVLW 0x00
MOVWF TRISA
BCF STATUS,5
loop CALL delay
COMF PORTA
GOTO loop
delay MOVLW 0x10
MOVWF 0x20
cyc DECFSZ 0x20
GOTO cyc
RETURN
END
The delay/cyc loop just sticks 16 in general register 0x20 and loops back to provide a delay for the rest of the loop, which just uses a COMF to (One would hope) invert all the bits in PORTA. But, it doesn't, which leads me to (correctly) assume that I've done something wrong.
In Proteus, it won't even do anything, and in Oshonsoft's PIC Simulator, it first turns all of PORTA on at the first iteration of the loop, but then only inverts one of the bits thereafter on each iteration. Could someone tell me what I did wrong? The code is simple, and seems solid...Maybe I'm just not using COMF correctly?