Throb
cavelamb
Posts: 720
Spin is seriously strange...
But it's what w have to play with so I'm trying to learn more.
Playing wit the Repeat loop...
I'm trying to give the blinky LED a bit more expressiveness.
It works going UP, the LED ramps up nicely.
But I can't seem to make it go back down smoothly.
I'm guessing the step value can not be negative?
Although SPIN didn't whine about it.
Or maybe it's something I did???
OOPS! Fixed...
so that both loops count uo,
(Thanks Mark)
But it's what w have to play with so I'm trying to learn more.
Playing wit the Repeat loop...
I'm trying to give the blinky LED a bit more expressiveness.
It works going UP, the LED ramps up nicely.
But I can't seem to make it go back down smoothly.
I'm guessing the step value can not be negative?
Although SPIN didn't whine about it.
Or maybe it's something I did???
OOPS! Fixed...
so that both loops count uo,
(Thanks Mark)
{ Feb 16, 2012 Throb1.spin } CON _CLKMODE=XTAL1 _XINFREQ =5_000_000 MSec = _XINFREQ / 5_000 USec = _XINFREQ / 5_000_000 Tsec = MSec *2 ' time for each step Tstp = 50 ' number of steps per cycle HI = 1 LO = 0 LED = 07 VAR Long X PUB MAIN dira [LED] := 1 ' output bit for LED outa [LED] := 0 ' start low Repeat Repeat X from 1 to Tstp step 1 outa[LED] := Hi ' high period waitCNT ((X * Tsec) +Cnt) outa[LED] := LO ' low period waitCNT (( Tstp - X+1 )*Tsec +cnt) Repeat X from 1 to Tstp step 1 outa[LED] := Hi ' high period waitCNT (( Tstp - X+1 )*Tsec +cnt) outa[LED] := LO ' low period waitCNT ((X * Tsec) +Cnt)
Comments
Thanks, Mark.
The other thing that doesn't seem quite right is the timing.
What I intended to do is set 5 MHz clock speed, then calculate microsec and
millisec values (in Usec and Msec, respectively)
But those milliseconds seem to be kinda short.
Tdel is a short delay at the ends of each ramp - a pause for effect.
But to make it show up at all I'm using 3500 * Milliseconds,
which should be 3.5 seconds, right?
Seems to be off by about a factor of 10?
Divide the frequency by 1,000 for ms and 1,000,000 for us. (In this case, I think it would work.)
debug.GildaVoice(string("Nevermind..."))