Using POSEDGE Counter Mode
blf
Posts: 6
I'm trying to use the counters on my Propeller to detect when I've pressed a button (specifically, one of the resistive touch buttons on the QuickStart development board). The following code is an attempt to get one of the LEDs (PIN 16) toggling on the press of the monitored button (PIN 0). Any ideas where I've gone wrong?
CON _CLKMODE = XTAL1 + PLL16X _XINFREQ = 5_000_000 PUB Main COGNEW(@MONITOR, 0) DAT ORG 0 MONITOR MOV DIRA, MASK ' Set Pin 16 As Output MOV FRQA, #1 ' Set FRQA to 1 MOV PHSA, #0 ' Clear PHSA (Should Already Be Clear) MOVS CTRA, %0000_0000 ' Set APIN MOVD CTRA, %0000_0000 ' Set BPIN MOVI CTRA, %01010_000 ' Set CTRMODE :CLEAREVENT MOV EVENT, PHSA ' Copy PHSA into EVENT :WAITEVENT CMP EVENT, PHSA WZ ' Check If EVENT has occurred IF_Z JMP #:WAITEVENT ' Pull XOR OUTA, MASK ' Toggle LED (Pin 16) JMP #:CLEAREVENT ' Do it Again MASK LONG $00_01_00_00 ' Pin 16 EVENT RES 1
Comments
Thanks! I had completely forgotten to specify immediate values with the hash character. That solved everything!