Hello,
I'm trying to figure out how to implement the Low Power (LP) mode on my 18F452 and then have the ability to switch between the main oscillator and the Timer1 oscillator at will while the program is up and running to conserve battery power. The project's power supply can be switched between operating off the mains to batteries and vise versa by plugging and or unplugging the transformer so while operating off the batteries I'd like to be able to have Timer1 use a 32 KHz crystal. I have a few questions on how to do this after reading the manual.
The manual for the 18F452 states that in order to be able to use the "Oscillator Switching Feature" that it has to be enabled by programming the (OSCSEN) bit in the Configuration Register1H to a 0. When I look at section 19-1: it shows that the OSCSEN is bit 5 but it's not a write-able bit. Further reading suggests to me that the only way to access this bit is in the CONFIG1H register and I'd have to use Table Reads and Table Writes to change that bit. I'm hoping I'm wrong as it's very confusing for me trying to figure out how to do that. Is there another way of doing this? Would selecting the LP mode by placing @ __CONFIG _CONFIG1H, _LP_OSC_1H at the beginning of my code set the OSCSEN bit to an 0 or does that just select the LP mode? I don't have my 32 KHz crystal yet to be able to try it.
Can anyone suggest a way of accomplishing this?
Thanks
jessey
Bookmarks