Searching \ for '32khz signal' in subject line. ()
Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=32khz+signal
Search entire site for: '32khz signal'.

Truncated match.
'32khz signal'
1999\09\23@181155 by

Hello Picsters!
HELP!

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
from tmro
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
analogue i/cs!
A subroutine of code with explanation greatly appreciated!

Kev

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.
--
Cheers,
Paul B.

"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.

Quentin

Hello Quentin.

> 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?
--
Cheers,
Paul B.

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...