Shop OBEX P1 Docs P2 Docs Learn Events
CTRA mode 01010 not working — Parallax Forums

CTRA mode 01010 not working

Red_DogRed_Dog Posts: 7
edited 2013-12-30 12:50 in Propeller 1
I'm trying write ASM code to scale an input signal by 1000 but something isn't working. To test it I have one Cog running CTRA as an NCO with the APIN set to output on pin 5 using a demo board. That part works. I have a second Cog running CTRA in POS mode (01010) accepting an input on pin 2. I have FRQA loaded with a value of #1 so that it increments PHSA by one each time it detects a positive on pin 2. I compare PHSA to 1000 and if equal, toggle pin 22 and reset PHSA to 0. I have pin 5 connected to pin 2 and expect to see pin 22 blinking at 1/1000th of pin 5, however it doesn't blink at all. I downloaded a trial version of Viewport and I see activity on pins 5 and 2 but I don't see any activity on pin 22. My hunch is that PHSA isn't incrementing by 1 when the signal on pin 2 goes positive and so PHSA is never equals 1000. I've tried testing it manually using PASD and a switch but I need a debounce circuit as PHSA increments by a random amount each time I release the switch. I've tested it by setting PHSA to 1000 with no input connected and it toggles like it's supposed to but doesn't scale. So my questions are:

1. Is there a way to monitor PHSA on a running cog? If Viewport does this I haven't found it and PASD only works on one Cog.
2. Is there any circuitry that needs to go between pins 5 and 2 to get it to work? I've tried a resistor but no go.
3. Is there anything I'm missing?

I appreciate any enlightenment you can provide.

Red Dog

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2013-12-29 22:39
    Red_Dog wrote: »
    I compare PHSA to 1000 and if equal, toggle pin 22 and reset PHSA to 0.
    Do you do it like this:
    cmp     phsa, d1000 wz
            ...
    d1000   long    1000
    
    In this case swap the operands, if you want to read phsx it has to be in the source slot of an insn. If that doesn't help post your code and we can go from there.
  • Red_DogRed_Dog Posts: 7
    edited 2013-12-30 12:50
    kuroneko you are a genius. I swapped the operands and it's working perfectly now.

    Thanks so much for your help

    Red_Dog
Sign In or Register to comment.