code problem
mikea
Posts: 283
The following will ramp up a led until i added the "repeat while ina[1]==1. I,ve spent a lot of time and i'm still stumped. In the future i want 2 buttons to ramp up/down a dc motor, but i'm stuck here. thanks for any help.-mike
CON _clkmode = xtal1 + pll16x ' System clock → 80 MHz _xinfreq = 5_000_000 PUB TestPwm | tC, tHa, t ctra[30..26] := %00100 ' Configure Counter A to NCO ctra[5..0] := 4 frqa := 1 dira[4]~~ 'pin for led dira[1]~ tHa:=1 tC := 10000 ' Set up cycle and high times t := cnt ' Mark counter time repeat repeat while ina[1]==1 'pushbutton held down phsa := -tHa ' Set up the pulse ++tHa t += tC ' Calculate next cycle repeat waitcnt(t) ' Wait for next cycle
Comments
Andy