generate pulse in asm
ratronic
Posts: 1,451
I am trying to generate a 5uS pulse continuosly. But I continue to generate a pulse of aprx .72uS no matter what
I put in for the delay amount. I have read the propeller book about waitcnt and read the waitcnt examples in the
first page· of the sticky asm for beginners in the front of this forum. Can anybody tell me what I am doing wrong in the attached code genpulse? I have read everything I can get my hands on. I am stuck!!!! Please help!!!
Thanks Dave!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Post Edited (ratronic) : 4/14/2007 12:53:25 AM GMT
I put in for the delay amount. I have read the propeller book about waitcnt and read the waitcnt examples in the
first page· of the sticky asm for beginners in the front of this forum. Can anybody tell me what I am doing wrong in the attached code genpulse? I have read everything I can get my hands on. I am stuck!!!! Please help!!!
Thanks Dave!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
D RatFix it if ain't broke·
Post Edited (ratronic) : 4/14/2007 12:53:25 AM GMT
Comments
You can use the same pin-mask to set and clear a portbit with or and andn. Your m0 mask make no sense, it will always stay at 0 (a 0 shifted left will stay a 0).
Don't set the pins with mov, this will affect all pins together (in this example it will work but what if there is an other cog that will use the port?). Use or/andn or mux.
waitcnt dest,src waits until the counter reaches the value of dest and adds then the value of src. In the code above the time value will be set to cnt+delay before the loop and in the loop the time value will be set to time+delay after every match for the next waitcnt instruction. The addition is done in the same cycle as the match occure - this gives a very exact timing.
Of course the inner loop can be made even shorter if you don't care about the initial state:
loop· xor········ outa,m1
······ waitcnt· ·time,delay
······ jmp······ ·#loop
·
Having trouble seeing why any of the above would work properly.
To me you all grab the cnt time value once as you start up but never grab it again.
See below
mov time, cnt 'get current cnt
add time, delay 'add delay time
Then you all loop without grabbing the cnt value again ???
Am I missing something here ??
Ronald
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ D Rat
The source field of the WAITCNT is automatically added to the destination after the wait is satisfied. This sets up the destination for the next WAITCNT at precisely the same time interval every time. For example:
Note that the WAITCNT waits for the current delay time, then sets up for the next delay time
Thanks Mike!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ D Rat
Post Edited (ratronic) : 4/14/2007 3:19:37 AM GMT
Thnx for that pointer.
That will shorten my code in a few spots.
Just verified the manual re your pointer .. yep your right.
That makes that a powefull instruction .. doing 2 things .
Cheers
Ronald Nollet Australia