|
|
View previous topic :: View next topic |
Author |
Message |
mahdihir
Joined: 01 Dec 2013 Posts: 7 Location: Iran
|
Timer1 in sleep mode |
Posted: Tue May 26, 2015 3:47 am |
|
|
My dear friend in CCS forum
I hope you are doing well.
I need to run a customized LCD with 6 digits in very low power consumption, I used PIC 16f684.
As you know, LCD works with 25 Hz. so I need to generate this frequency with timer1. I connect pin A03 for COM and sent timer signal to this pin.
In order to ON each digit in lcd, must have reverse signal, its means if COM is 1, digit1 must be 0 .
Obviously if COM is 1 and digit1 is also 1, the digit1 is OFF.
I connected all 6 digits to port C (C0-C5).
My questions are:
1: is timer1 works in sleep mode?
2: if I have timer signals in pin A03, how to send reverse signals to port (c0-c5) separately?
Thanks _________________ There is more than one solutions for any problem . |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Tue May 26, 2015 8:01 am |
|
|
The timer itself, does not operate any pins. The timer _counts_ signals from a clock source (the T1CKI pin if used asleep). That is all it does. You _can_ enable the oscillator between OSC2, and T2CKI, and this can keep operating when the chip is asleep, and the timer will count this, _provided it is running in async mode_. If 'sync' is selected, the timer will stop. The timer cannot run from the internal oscillator when asleep (some ore complex chips have a separate low power internal oscillator that can run when asleep - your's doesn't).
When you wake (the timer overflows), you can simply output any pattern of signals you want on any pins. The LCD does not 'need' 25Hz changes, it will need a signal just reasonably close to this. Most will run from signals a large factor 'wrong' (they will run off clocks derived from very simple RC circuits).
Now, to get Timer1, to 'naturally' wake at 25Hz intervals, you would need a clock at 16MHz. Far beyond the speed supported by the oscillator. So you are going to have to 'cheat' and set the timer forward to get the wake up rate. So assuming a cheap crystal, like 32768Hz, on the two timer pins, the sequence would be:
Setup the timer for async operation, and enable the oscillator.
Enable the timer interrupt _but do not enable the global interrupt_.
Then loop:
Clear the timer interrupt
Set the timer to perhaps 64230
Sleep
nop instruction here (delay_cycles(1));
Output the next pattern of bits for the LCD
go back to loop
This way the chip will go to sleep and count from 64230, to 65536, then wake (so 1306 counts - 1/25th second at 32768Hz), then output the next LCD bit pattern, and go back to sleep. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|