OSCCON's affect on PWMOUT and READADC 08M

premelec

Senior Member
Couldn't find specfic previous post on this - For 08M

Will READADC work correctly when OSCCON is poked with various values?

Will PWMOUT be proportionately affected by the OSCCON poked value?

I want to use a pot on READADC to determine PWMOUT frequency without changing duty cycle... In short poke OSCCON depending on READADC value [only allowed poke values]: Is this going to work?

Thanks...
 

BeanieBots

Moderator
Never had any problems using ReadADC with any value of OSCON.
Not looked at the effect on PWM but would ASSUME it to be related.
 

womai

Senior Member
From what I know readadc uses the dedicated RC oscillator as its sample clock, so that should not be affected in any way by changing OSCCON (which chnaged the speed of the master clock, but does nothing to the RC oscillator).

As for PWM it is the other way around, the PWM frequency is a divided-down master clock, so it will scale accordingly.
 

premelec

Senior Member
Thanks BB & Womai - that's the way I hoped it was but didn't know that AD had entirely separate oscillator - On to the real world... :)
 

womai

Senior Member
On a "real" PIC you can select if you want your sample clock to be based on the (divided-down) master clock or on the RC oscillator, respectively. The former has the advantage of very predictable conversion time, whereas the RC oscillator's frequency can vary over quite a wide range, I believe something like 150 to 500 kHz, from part to part and depending on temperature; that can be an issue if you need tight timing, but it's hardly an issue on a slow Picaxe with its somewhat non-deterministic execution timing.

If you want to dig deeper, have a look at the "pedestrian" readadc routine I posted recently, which gives you access to all those settings (although I haven't verified whether the clock selection works or if the Picaxe firmware prevents changes there).

http://www.picaxeforum.co.uk/showthread.php?t=13553

The underlying PIC data sheet is also a worthy reading for all the details.

Wolfgang
 
Top