I am trying to generate an approximate 32khz signal on a gpio of a 12c508/a
running at int osc.
Bsf for 1/2 cycle Bcf 1/2 cycle.
prescale 4, used but not essential! I have tried 4 x X = and subtracting
but frequency is "miles out"
Could use lots of "nops" but that isnt learning!
Can't you tell I am new to the world of PICS, I am used to 40106 cmos and
A subroutine of code with explanation greatly appreciated!
Kev Howard wrote:
> I am trying to generate an approximate 32khz signal on a gpio of a
> 12c508/a running at int osc.
OK, how close do you want? If the internal oscillator runs at 4 MHz
nominal, you have a 1 MHz instruction clock. A complete cycle at 32 KHz
requires 31.25 instructions, so if you approximate to 31 instructions
you get a frequency of 31,250 Hz plus or minus a few percent.
You simply need a loop of 30 instructions (including one branch which
takes two instructions) with the bit set and bit clear instructions
placed equal delays apart.
Neither TMR0 nor prescaler has any part in this, the operation is too
fast. They are appropriate for timings in the millisecond range.
"Paul B. Webster VK2BZC" wrote:
> A complete cycle at 32 KHz
> requires 31.25 instructions, so if you approximate to 31 instructions
> you get a frequency of 31,250 Hz plus or minus a few percent.
You can do "leap" cycle. every 4th cycle you do one instruction extra.
> You can do "leap" cycle. every 4th cycle you do one instruction extra.
That's the sort of business I was going into earlier - another thread.
*However*, did you happen to note that he is using the internal
oscillator of the 12C508?
More... (looser matching)
- Last day of these posts
- In 1999
, 2000 only
- New search...