View previous topic :: View next topic |
Author |
Message |
cvargcal
Joined: 17 Feb 2015 Posts: 134
|
Auto-wake-up from sleep |
Posted: Sun Sep 23, 2018 10:41 am |
|
|
Hi, I read the manual from 18LF26K22 and this pic has "auto wake up" how I do in CCS?
Code: |
void main() {
while(TRUE)
{
printf(" To slepp....);
printf("\n\n");
delay_ms(1000);
sleep(); // make processor sleep
}
} |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Sun Sep 23, 2018 10:58 am |
|
|
it'll wake up if an interrupt occours, wdt times out or a 'reset' happens. These are programmable events... YOU have to code for them. How and what 'wakes up' the PIC is up to you....
Jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 23, 2018 11:00 am |
|
|
Is this what you want to do ?
Quote: | 16.4.3 AUTO-WAKE-UP ON BREAK
During Sleep mode, all clocks to the EUSART are
suspended. Because of this, the Baud Rate Generator
is inactive and a proper character reception cannot be
performed. The Auto-Wake-up feature allows the
controller to wake-up due to activity on the RXx/DTx
line. This feature is available only in Asynchronous
mode. |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Sun Sep 23, 2018 11:31 am |
|
|
Hopefully you understand that this requires a serial break character to wake the chip?. It's not a generic wake up. Hence PCM_Programmers question.
setup_uart(UART_WAKEUP_ON_RDA);
enables this feature. |
|
|
cvargcal
Joined: 17 Feb 2015 Posts: 134
|
|
Posted: Sun Sep 23, 2018 1:24 pm |
|
|
Ttelmah wrote: | Hopefully you understand that this requires a serial break ....... |
Thanks...
mmm I saw one device with the micro STM32.. the device is only the micro and chip radio Lora... this device wakeup every X time and send a data short.
Really has not many circuit and not has other IC.... maybe the micro has a task RTC for counter the time while sleep and not consume many energy? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Sun Sep 23, 2018 1:53 pm |
|
|
Your chip doesn't have an RTC. It does though have the watchdog. This can be set to give a timeout in binary multiples from 4.1mSec to 131seconds, and can wake from sleep. Select the fuse WDT_SW, which allows it to be controlled in software, and you can then enable this before sleep. Depending on your supply voltage, this adds a couple of uA to the sleep current. |
|
|
cvargcal
Joined: 17 Feb 2015 Posts: 134
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Mon Sep 24, 2018 12:49 am |
|
|
Yes, you can use Timer1, but this requires you to add a 32768Hz crystal for this. It is down to what accuracy you need for the time, and what hardware you are prepared to add.
Understand that the chip draws significantly more when any of the oscillators are run while asleep. The WDT requires the LFINTOSC. Timer1 requires the secondary oscillator. The secondary oscillator can draw up to 10uA (worst case), and the LFINTOSC 5uA worst case. In many cases it draws much less power to use an external clock chip. So (for instance), add a MCP79410 or similar RTC, and you have time being maintained for you at all times, at a cost of just 1.2uA consumption (some other types even lower). You can program this to give a trigger pulse every second, or every minute, and wake when this triggers. With 1/min, this allows you to stay asleep much more of the time. Hence even lower overall power usage. |
|
|
cvargcal
Joined: 17 Feb 2015 Posts: 134
|
|
Posted: Mon Sep 24, 2018 8:36 pm |
|
|
Ttelmah wrote: | Yes, you can use Timer1, but this requires you to add a 32768Hz crystal for this. It is down to what accuracy you need for the time, and what hardware you are prepared to add.
Understand that the chip draws significantly more when any of the oscillators are run while asleep. The WDT requires the LFINTOSC. Timer1 requires the secondary oscillator. The secondary oscillator can draw up to 10uA (worst case), and the LFINTOSC 5uA worst case. In many cases it draws much less power to use an external clock chip. So (for instance), add a MCP79410 or similar RTC, and you have time being maintained for you at all times, at a cost of just 1.2uA consumption (some other types even lower). You can program this to give a trigger pulse every second, or every minute, and wake when this triggers. With 1/min, this allows you to stay asleep much more of the time. Hence even lower overall power usage. |
Thanks you.. so the better way is one RTC ... these one pic with this function? or the best case is one ic external? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Mon Sep 24, 2018 11:50 pm |
|
|
The PIC's are not as efficient as RTC's, as chips designed to do this. The dedicated chips use internal structures that are designed for low power.
It is all down to parameters you are not telling us.
How accurate does your sleep time need to be?.
How low do you need the power consumption to be?.
How frequently do you need to wake up?.
How accurately does the system need to actually keep 'time'?. |
|
|
|