Shop OBEX P1 Docs P2 Docs Learn Events
AN001 document on detecting negative edge question — Parallax Forums

AN001 document on detecting negative edge question

HarleyHarley Posts: 997
edited 2008-09-15 01:37 in Propeller 1
I would like to use mode %01110 to detect when a negative edge occurs on a pin, A18.

From the AN, it appears that %01110_000 << 26 + 18 would be the initialization for it.

However, I don't see any info on how one determines that a negative edge has occurred. Like, is it via PHSx register? And how is the flag bit presented; ls bit? Does the user have to clear the register after detecting a neg edge to be ready for a following one? Such info is difficult to glean from this AN. Anyone used this mode yet?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-09-14 22:31
    To detect an edge like this with a counter, you can set FRQx to one, clear PHSx to zero, then wait for PHSx to become non-zero. Or you can just go about your other business and read PHSx occasionally. It will contain the number of edges that have transpired since last being cleared (barring any rollover, of course).

    Using a counter to detect edges will not locate the exact time of the edge as accurately as a combination of two WAITPEQs will, however, due to the test loop overhead.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • HarleyHarley Posts: 997
    edited 2008-09-14 23:30
    Thanks Phil,

    Looks like, even though such features are available, there is that 'missing' one like what interrupts provide.

    Possibly will have to use an extra Cog will be required along with the delayed 'communications' with another to tell it 'Negative edge occurred' some time ago. I've got to rethink this situation over.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-09-15 00:05
    Harley said...
    Looks like, even though such features are available, there is that 'missing' one like what interrupts provide.
    I disagree, of course. (But I'm sure you knew that! smile.gif ) Interrupts, being merely a way to simulate multiple processes, provide nothing of which the Propeller isn't already capable.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • HarleyHarley Posts: 997
    edited 2008-09-15 00:32
    Phil said...
    I disagree, of course. (But I'm sure you knew that! ) Interrupts....

    Yes, I understand. Only less than a decade I finally understood how to deal with interrupts using PICs, so I was coming late into the game. Then the Propeller came along and WOW! But I can't seem to figure out how to work around and capture an event ASAP with the Prop, yet. Maybe that last word is the key word.

    I'm simulating lots of TTL with Prop SPIN and assembly. Much (some 50+ TTL parts) is stuffed into two Props; one would have been enough but needed more than 33 I/Os.

    Trying to come up with some speedy routines, like catching a negative edge quickly while doing many other things, is where the 'hard' work now is. (I didn't comprehend your suggestion of two WAITPEQs. Got a few words of your thinking on this? Thanks, Phil.)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
  • SapiehaSapieha Posts: 2,964
    edited 2008-09-15 00:42
    Hi Harley.

    Think every COG as one PIC interupt in simple words.
    It is more complicated but basic is 1 COG one program that RUN parallel = One PIC interupt.
    If You must wait on one Interupt PIN in some chip that have that You can conect it tu one Prop PIN and wait on its event

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.
    For every stuipid question there is atleast one inteligent answer
    If you dont ask you wont know

    Sapieha
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-15 00:44
    If you know for sure that the signal is high before entering this routine and will remain high for at least 5 clock cycles, you need only do

    WAITPEQ ioPinMask,#0
    MOV changeTime,CNT
    SUB changeTime,#3

    and you will capture the time of the edge (I may have the constant wrong, but you get the idea). The WAITPEQ will stall the cog until the I/O pin changes to a zero, then will restart execution on the next system clock. I believe there's one full instruction clock for the WAITPEQ, then the MOV requires two clock cycles to fetch the source value (CNT). That makes 3 clock cycles.

    If you don't know the state of the input signal, you will need to wait for it to be high with "WAITPNE ioPinMask,#0" first.
  • jazzedjazzed Posts: 11,803
    edited 2008-09-15 00:50
    Phil Pilgrim (PhiPi) said...
    ·... provide nothing of which the Propeller isn't already capable.
    Until you need more than 8 of course [noparse]:)[/noparse]· Then you have to dig harder. WAITPEQs are useful and as in everthing else usually, they have limits too.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve
  • SapiehaSapieha Posts: 2,964
    edited 2008-09-15 01:23
    Hi jazzed..

    You said.
    ""Until you need more than 8 of course."

    Yes or No.

    If it is Lo priority smal PASM programs without WAITPxx

    COGPROG.
    Prog 1
    · INA Pin x
    · On Pin x Call Prog2
    · xxx
    · xxx
    · xxx
    · xxx
    · Jump Prog 1
    Prog 2
    · xxx
    · xxx
    · xxx
    · xxx
    · Jump Prog 1



    Ps. Is it litle more complicated but it is basic· structure

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.
    For every stuipid question there is atleast one inteligent answer
    If you dont ask you wont know

    Sapieha

    Post Edited (Sapieha) : 9/15/2008 1:32:11 AM GMT
  • jazzedjazzed Posts: 11,803
    edited 2008-09-15 01:37
    "Until you need more than 8 of course [noparse]:)[/noparse]" is a reference to the number of tasks prop can run without resorting to doing strategic jmprets in PASM or simulated task switching with LMM which is close the way it's done with an interrupt strategy in other CPUs. Nevertheless, Propeller is very flexible even with the "great reaching" necessary sometimes ... that's why I use it. Cheers.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve
Sign In or Register to comment.