AN001 document on detecting negative edge question
Harley
Posts: 997
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
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
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!
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
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
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
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.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve