Hi all,
I am testing the 12F629 found something very weird. The PIC is suppose to flash two LEDs on GP0 and GP1.
1. The movlw b'00001111' to set TRISIO is not a typo - bit 0 and bit 1 are supposed to be zero for output, but LEDs won't flash unless I set them to one!
:shock:
I ran the MPLAB simulator, and:
2. bsf GPIO, GP1 will set GP1 bit to zero! :?
3. bcf GPIO, GP0 will set GP0 bit to one! :roll:
Anyone has any idea what's going on?
Here is the code:
I am testing the 12F629 found something very weird. The PIC is suppose to flash two LEDs on GP0 and GP1.
1. The movlw b'00001111' to set TRISIO is not a typo - bit 0 and bit 1 are supposed to be zero for output, but LEDs won't flash unless I set them to one!
:shock:
I ran the MPLAB simulator, and:
2. bsf GPIO, GP1 will set GP1 bit to zero! :?
3. bcf GPIO, GP0 will set GP0 bit to one! :roll:
Anyone has any idea what's going on?
Here is the code:
Code:
org 0x00
goto init
init bcf STATUS, RP0 ; Bank 0
clrf GPIO ; Init GPIO
movlw 07h ; Set GP<2:0>
movwf CMCON ; digital IO. Turn off comparator
movlw b'00001111' ; GP<1:0> output GP<3:2> inputs
movwf TRISIO ;
bsf STATUS, RP0 ; Bank 1
main bsf GPIO, GP1
bcf GPIO, GP0
call delay
bcf GPIO, GP1
bsf GPIO, GP0
call delay
goto main
delay ;;;;; delay routine ;;;;;;