PASM Complete Prop lockup
TJHJ
Posts: 243
So I can not seem to figure out what is going on and why everything justs stops. I am using a UOLED-128-GMD1 as an output to check calcualtion and such.
It stops updating as soon as the new cog with the PASM is stared.
So as a challange to learn asm, I thought I would make a semi PWM thing, should help me get the basics down.
The goal is output one freqency on a pin to go to a transformer to make ac, through a fet.
Then place a diode, so its 1/2 wave rectified, while the first pin is high, take another mosfet and and turn it into a frequency, by deviding it into equal segments.
I came up with this as something that I could look at with the scope and see, but also something I can not do in spin. Instead of using the counters I am using looped wait commands. To try out and see 1st hand the PASM speed.
So any suggestions ideas?
Thank you all as always.
TJ
It stops updating as soon as the new cog with the PASM is stared.
So as a challange to learn asm, I thought I would make a semi PWM thing, should help me get the basics down.
The goal is output one freqency on a pin to go to a transformer to make ac, through a fet.
Then place a diode, so its 1/2 wave rectified, while the first pin is high, take another mosfet and and turn it into a frequency, by deviding it into equal segments.
I came up with this as something that I could look at with the scope and see, but also something I can not do in spin. Instead of using the counters I am using looped wait commands. To try out and see 1st hand the PASM speed.
So any suggestions ideas?
Var long start long freqon long freqoff long Ondelay long internaldutytime long dutycount long data long cog long stack1[noparse][[/noparse]50] long TotalTime Pub run (freqonIN, FreqoffIN, secondSegmentNumber, SecondSegmentTime ondelaytime) Freqon := FreqonIN Freqoff := FreqoffIn dutycount := SecondSegmentNumber internalDutytime := secondsegmentTime ondelay := ondelaytime cognew(screen,@stack1) ' Runs a repeat loop ouputting the above numebrs to a screen and count updated every 1 second so I can make sure its working. waitcnt(clkfreq*3 +cnt) ' let the screen load up cognew(@entry, @start) ' start the pasm Dat org entry mov location, par 'get first location add location, #4 ' Move 1 increment long wrlong freqonloc, location ' Store adress of freq in freqloc add location, #4 ' move another loc long wrlong freqoffloc, location ' Store adress of freq in freqloc add location, #4 wrlong ondelayloc, location ' ondelay location add location, #4 'Move 1 long wrlong internaldutytimeloc, location ' internal duty location add location, #4 wrlong dutycountloc, location ' internal dutycount location add location, #4 or dira, mask1 'set pins output or dira, mask2 :dataup rdlong freqon1, freqonloc 'store data, yeah I know i have to wait for the access window, but figured it would be easier to debug. rdlong freqoff1, freqoffloc rdlong ondelay1, ondelayloc rdlong internaldutytime1, internaldutytimeloc rdlong dutycount1, dutycountloc :loop andn outa , mask1 ' turn off Pin1 and pin2 andn outa, mask2 mov time, cnt ' Wait low side of pulse waitcnt time, freqoff1 or outa, mask1 ' Turn on pin1, highside time. wrlong loopcount, dutycount1 ' Set loopcount to the small duty count mov time, cnt 'Wait for the on delay % waitcnt time, ondelay1 :onloop or outa, mask2 ' Pin1 is on, turn on pin 2 mov time, cnt waitcnt time, internaldutytime1 ' Waitcnt small segment loop andn outa, mask2 'turn off pin 2 mov time, cnt waitcnt time, internaldutytime1 ' Waitcnt small segment loop sub loopcount, #2 'subtract 2 from loopcount tjz loopcount, :loop ' Jump to main loop if loopcount = 0 jmp :onloop ' go back to onloop if we havent finished our on time yet. dataupdated res 1 location res 1 freqonloc res 1 freqoffloc res 1 ondelayloc res 1 internaldutytimeloc res 1 dutycountloc res 1 time res 1 freqon1 res 1 freqoff1 res 1 ondelay1 res 1 internaldutytime1 res 1 dutycount1 res 1 loopcount res 1 mask1 long |< pin1 mask2 long |< pin2
Thank you all as always.
TJ
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I am 1011, so be surprised!
Advertisement sponsored by dfletch:
Come and join us on the Propeller IRC channel for fast and easy help!
Channel: #propeller
Server: irc.freenode.net or freenode.net
If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
Also,
the lines that read ...
mask1 long |< pin1·················
mask2 long |< pin2
... should come before your 'res 1' statements.
Can you provide some example parameters that you are using for ... freqonIN, FreqoffIN, secondSegmentNumber, SecondSegmentTime, ondelaytime
It would also help to use the "File->Archive->Project" option to create and attach future files.
Edit: taking another glance...
take a look at how you are using the waitcnt command...
······· mov time, cnt······························· ' Wait low side of pulse······
······· waitcnt time, freqoff1
...when you move cnt into time, and then wait for that value, the event is already gone and you have to wait until the counter rolls over.
Instead, do something like this...
······· mov time, cnt······························· ' Wait low side of pulse······
······· add time, freqoff1························· ' <-- This sets the time variable to a value that is some amount of time into the future that·the counter has not reached yet
······· waitcnt time, #0
...The 'Delta' option I set to #0 above, but it might be worth looking into for your application.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 9/26/2008 8:20:12 PM GMT
As requested here is the archive file, with a testrun function on the top.
Maybe someone else will get some use out of it, if it can be fixed.
Thanks again,
TJ
For the edit, thanks Beau,
mov time, cnt······························· '·the current counter is·now stored in time.
waitcnt time, freqoff1··················· ' Im not waiting for time+freqoff1? to reach in the counter?
' time should be the current counter value, and waitcnt is waiting for time+ freqoff1?·Or am I misreading that in that it doesnt add them when it runs the waitcnt command.
Post Edited (TJHJ) : 9/26/2008 8:32:53 PM GMT
"time should be the current counter value,..." - that's correct here...
mov time, cnt
...but when you get to here...
waitcnt time, freqoff1
...the value for 'cnt' has already passed the value your testing against.... 'time'
"...and waitcnt is waiting for time+ freqoff1?" - No, waitcnt will wait for 'time' to equal the value of the counter.· When that condition is met, then 'freqoff1' will be added to 'time' and stored in 'time' in·anticipation for the next waitcnt.· In this case 'freqoff1'·becomes a delta offset to preset any subsequent waitcnt instructions.
The way you have it, waitcnt will sit there for about 54 seconds (assuming your running at 80MHz) because the initial counter value was missed.
(2^32/80_000_000) = 53.6 seconds
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 9/26/2008 10:22:18 PM GMT
Thanks for the help
TJ