PDA

View Full Version : How to DEFINE OSC, in case of 32khz clock frequency?



CuriousOne
- 11th August 2015, 11:28
Hello.

To reduce power, I want to run 12F1840 @ 32khz, but since there is no DEFINE OSC for that frequency, all timings are messed up. Any ideas how to fix it?

rmteo
- 11th August 2015, 16:22
Hello.

To reduce power, I want to run 12F1840 @ 32khz....
http://www.picbasic.co.uk/forum/showthread.php?t=20161

CuriousOne
- 11th August 2015, 20:40
So the answer is NO ?

pedja089
- 11th August 2015, 22:00
Correct timing for pbp is critical only for serin, serout,serin2, serout2, owin, owout, pause, and pauseus.
32KHz is too slow for serin, serout, serin2, serout2, owin and owout, probably.
So you are left only with pause.
Instead trying to force PBP to 32KHz, create your own pause.
Instruction clock is just around 8KHz, to be precise 8192Hz
So you need only 8 instruction to get 1,024mS

My1msPause:
ASM
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
ENDASM
And work from there to get pause that you need.

AvionicsMaster1
- 12th August 2015, 03:57
Ifn you're trying to conserve power you really need to look into SLEEP and IOC. Both can cut power consumption significantly and are much easier to implement that ASM. OK, that's IMLTHO but you never know.

mark_s
- 12th August 2015, 16:39
Agree with using sleep and IOC. Years ago I had a similar problem. I contacted Charles at Melabs
he gave me a solution where you set osccon to 500Khz which reduces the current to a couple hundred microamps (vdd3.3v). Then trick PBP by multipling your baud rates and dividing your pause statements. DEFINE OSC 4mhz, set osccon to 500khz. The pic will be running 8 times slower. So if you wanted a PAUSE 1 you would make it PAUSEUS 125. Serial out at 2400 baud would be written at 19200. For shorter pause statements you could use nops as suggested above. This combined with sleep you can acheive very low current consumption on average and still use PBP. Also this chip has clock switching between 31khz and high frequency, which you might want to study.

CuriousOne
- 13th August 2015, 04:42
The main problem is that PAUSEUS is not working properly. It won't give you short enough pulses as needed. I've opened thread on that matter before, with precise measurements given.

richard
- 13th August 2015, 05:58
PAUSEUS is not working properly NOT REALLY

the smallest possible delay from pauseus @32khz is about 3mS . the smallest asm delay would be 125uS ie NOP

AvionicsMaster1
- 13th August 2015, 13:45
Are you using 12F1840 or the 12LF1840? Ifn I read the datasheet correctly you can achieve some significant power savings with the LF that you may not have to do the hokey pokey with the oscillator frequency. Though the LF is about 10% more cost if it gets you to your goal it may be worth it.

Is this a battery application or an experiment? Just curious why a few nA would be important.