[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/diy/ - Do It Yourself

Search:


View post   

>> No.1421415 [View]
File: 96 KB, 297x237, katen.png [View same] [iqdb] [saucenao] [google]
1421415

Novice Picfag here. When I run this the GPIO 4 is not set, even though the instruction is being executed. send help picfaglords. All I want is to flash a led when I press something.
#include "p12f675.inc"

FSR EQU 04 ; not used here
INDF EQU 00 ;not used
org 0x000
goto MAIN
org 0x004
goto EXINTR

MAIN:
bsf STATUS, RP0 ; goes to bank 1 to set TRISIO
bcf TRISIO, 4 ;sets gp4 as output
bcf STATUS, RP0 ; goes back to bank 0
clrf GPIO ;clears the io
bsf OPTION_REG, INTEDG ; sets to interrupt of positive change
bcf INTCON, INTF ; clears the interrupt flag
bsf INTCON, INTE ;enables external interrupt
bsf INTCON, 7 ;global interrupt set
clrf ANSEL ;sets stuff to digital io I think?

PT1: SLEEP
goto PT1 ;sleeps until interrupt

EXINTR:
btfss GPIO, GP4
goto BITSET ;jumos to setting the bit
bcf GPIO, GP4 ; clears bit
goto RETI ; exits interrupt
BITSET:
bsf GPIO, GP4
RETI:
bcf INTCON, INTF
RETFIE

end

Navigation
View posts[+24][+48][+96]