Shop OBEX P1 Docs P2 Docs Learn Events
Using POSEDGE Counter Mode — Parallax Forums

Using POSEDGE Counter Mode

blfblf Posts: 6
edited 2014-04-03 18:01 in Propeller 1
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

  • kuronekokuroneko Posts: 3,623
    edited 2014-04-03 17:47
    Think about it, what does MOVS CTRA, %0000_0000 do?
  • blfblf Posts: 6
    edited 2014-04-03 18:01
    @kuroneko

    Thanks! I had completely forgotten to specify immediate values with the hash character. That solved everything! :)
Sign In or Register to comment.