Shop OBEX P1 Docs P2 Docs Learn Events
Trouble with CTRA — Parallax Forums

Trouble with CTRA

realolmanrealolman Posts: 65
edited 2009-01-26 22:07 in Propeller 1
I would like to use the CTRA , but I am having trouble.


PUB CountInput 

Dira[noparse][[/noparse]11..21]~~ 
Dira[noparse][[/noparse]10]~
 

'set counter to positive edge detector 

CTRA := %01010 << 26 

ctra := ctra + 10 'sets counter to use pin 10 

'read accumulator value and place on pins
 
phsa :=3
repeat 

 Outa[noparse][[/noparse]17..21]:=phsa


I have a switch with a 12k pull down resistor hooked to P10.
At this point I am not concerned with much of anything, except I think I should see some activity on pins 17-21 and I see nothing... what am I doing wrong.

I would like to be able to determine if the thing is in fact counting.· I preset phsa to 3 just to see it on pins 17- 21 and it is there, but no counting

Post Edited (realolman) : 1/26/2009 9:48:25 PM GMT

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-01-26 21:45
    You need to set frqa to a non-zero value, so phsa will count up.

    -Phil
  • realolmanrealolman Posts: 65
    edited 2009-01-26 21:49
    That did it thank you· smile.gif
  • Paul BakerPaul Baker Posts: 6,351
    edited 2009-01-26 22:07
    I know that you are following the advice of another forum member, but its better practice to use ctra := %01010 << 26 + 10.
    The reason for this is it's insensitive to whether you set frqa before or after setting ctra. If you set frqa before setting ctra, by setting pina after setting the mode, you have actually started the counter using pin 0 until the next instruction is executed so you may get an erronious count depending on whats happening on pin 0.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
Sign In or Register to comment.