Help Using Counter to Flash LED In a Set it And Forget it Fashion
Juliet Oscar Echo
Posts: 31
I need help getting an LED to flash at 2 Hz in a set it and forget it fashion. I don't want to use a cog just to flash an LED. I know there's got to be a way to do it using a single counter, but so far no joy.
The following is from the Counter Modules and Circuit Applications Lab in the Propeller Education Kit Labs: Fundamentals. It will flash an LED connected to pin 12, but because of the "repeat" command, it's not a set it and forget it use for the counter.
I also tried looking on the OBEX and previous posts, but all the LED flashing applications I came across had way too many bells and whistles. All I need is a simple on / off.
I know this is very basic. Any help would be much appreciated.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
PUB Start_Flash_Alarm | tc, tHa, t
ctra[30..26] := 100
ctra[5..0] := 12
frqa := 1
dira [12]~~
tC := clkfreq
tHa := clkfreq/4
t := cnt
repeat
phsa := -tHa
t += tC
waitcnt(t)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following is from the Counter Modules and Circuit Applications Lab in the Propeller Education Kit Labs: Fundamentals. It will flash an LED connected to pin 12, but because of the "repeat" command, it's not a set it and forget it use for the counter.
I also tried looking on the OBEX and previous posts, but all the LED flashing applications I came across had way too many bells and whistles. All I need is a simple on / off.
I know this is very basic. Any help would be much appreciated.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
PUB Start_Flash_Alarm | tc, tHa, t
ctra[30..26] := 100
ctra[5..0] := 12
frqa := 1
dira [12]~~
tC := clkfreq
tHa := clkfreq/4
t := cnt
repeat
phsa := -tHa
t += tC
waitcnt(t)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comments
Andy