Need help for this code
Hello , i wrote this code to generate a frequency from 1Hz to 4KHz with duty cycle 50% , but the output on pin 1 isn't not for my need , no frequency :
CON
_clkmode = xtal1 + pll16x ' clk speed = external * 16 for 80 mhz
_xinfreq = 5_000_000 '5mhz external crystal
Pinout = 1
Var
long FreqOn, FreqOff
Pub Run|i
repeat
repeat i from 1 to 4000
FreqDuty(i,50) ' this will generate a loop from 1hz to 4,000hz then start over.
Pub FreqDuty(Frequency, Duty)
waitcnt((( clkfreq/frequency)*(100-Duty))/100 +cnt) ' wait for off part of duty cycle
outa[noparse][[/noparse]pinout]~~ 'Pin High
waitcnt((((clkfreq/frequency)*duty)/100) + cnt) ' Now the pin is high wait for the on part.
outa[noparse][[/noparse]pinout]~ ' Make the pin LOW
CON
_clkmode = xtal1 + pll16x ' clk speed = external * 16 for 80 mhz
_xinfreq = 5_000_000 '5mhz external crystal
Pinout = 1
Var
long FreqOn, FreqOff
Pub Run|i
repeat
repeat i from 1 to 4000
FreqDuty(i,50) ' this will generate a loop from 1hz to 4,000hz then start over.
Pub FreqDuty(Frequency, Duty)
waitcnt((( clkfreq/frequency)*(100-Duty))/100 +cnt) ' wait for off part of duty cycle
outa[noparse][[/noparse]pinout]~~ 'Pin High
waitcnt((((clkfreq/frequency)*duty)/100) + cnt) ' Now the pin is high wait for the on part.
outa[noparse][[/noparse]pinout]~ ' Make the pin LOW
Comments