help with pwm code
i'm trying to troubleshoot a problem with some code and can't seem to pin point the source of the problem. i've posted the code. i know the code is sloppy, but please bear with me. i now know there are better ways to pass variables to assembly, but as an exercise i still wanted to make this work.
i'm trying to combine two 16 bit values to one 32 bit value "pass" to pass to the assembly routine. i believe the problem is with the assembly line "shr left, #16". the problem occures when the variable "left " exceeds decimal 511, or 9 bits. the instruction table on page 350 of the PM shows that the source and destination are 9 bit values but i thought that these could be used as pointers to long variables
edit: oops!·the code is·posted now.
Post Edited (agfa) : 8/23/2008 3:00:18 PM GMT
i'm trying to combine two 16 bit values to one 32 bit value "pass" to pass to the assembly routine. i believe the problem is with the assembly line "shr left, #16". the problem occures when the variable "left " exceeds decimal 511, or 9 bits. the instruction table on page 350 of the PM shows that the source and destination are 9 bit values but i thought that these could be used as pointers to long variables
edit: oops!·the code is·posted now.
Post Edited (agfa) : 8/23/2008 3:00:18 PM GMT

Comments
I would do something like this
PUB go | x cognew(@entry, @pass) repeat repeat x from 0 to 125 'linearly advance x from 0 to 125 pass.word := x + 406 'left speed increments from 0 to 100% pass.word[noparse][[/noparse]0] := 531 - x 'right speed decrements from 100 to 0% 'pass:=l<<16'+r 'combines the speed values to one variable waitcnt(5_000_000 + cnt) 'wait a little while before next update DAT 'for audio PWM, fundamental freq which must be out of auditory range (period < 50µS) org entry mov dira, diraval 'set pins 12 and 13 to output mov ctra, ctraval 'establish counter A mode's APIN mov ctrb, ctrbval ' " " b " Apin mov frqa, #1 mov frqb, #1 'set counter to increment 1 each cycle mov time, cnt 'record current time add time, period 'establish next period :loop rdword left, par 'set "value" to the address of pass mov value,right add value,#2 rdword right,value waitcnt time, period 'wait until next periodPost Edited (Erik Friesen) : 8/23/2008 4:17:58 PM GMT
thanks for looking at it, and for the suggestion.
agfa
edit: could you clarify what the edit problem was?
Post Edited (agfa) : 8/23/2008 4:41:21 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.