- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need to enter Deep Sleep mode for about 15 seconds, then exit and run a scan for 3 seconds, then repeat this process. I also have 2 control pins set up to receive a button press. When the buttons are pressed, I also need to exit deep sleep mode. I have some audio that will play as well as a message sent out upon the buttons being pressed, so I can't be in Deep sleep for that.
I have the project running just fine without deep sleep enabled. Currently, i'm using a timer to count to a set number then run the scans, however this is draining the battery quickly.
The previous programmer working on this project has set up a WatchDog Timer with an interrupt.
WDT.c
Here he initializes the watchdog timer in main.c as seen below:
In addition to this, he has the LFCLK set to the external Watch Crystal Oscillator, which is what i'd want to use, according to everything i've read so far.
I suppose my idea was to enter low power mode and let the watchdog count to about 15 seconds, then use the interrupt to pull me out of low power, then scan. At the end of the scan, the function would put me back into low power mode, etc. There is one major problem with this - that I have no idea how to "count" time when the watchdog is operating. Further, I don't know if that's possible. As far as the buttons, I have absolutely no idea how to get me out of low power there.
Also, I ended up testing the "EnterLowPowerMode()" function from HERE. It tries to first go into deep sleep, if it fails, then it tries to enter sleep. I first tried the code with sleep only, and my device stops advertising, but the voltage draw is very low. On the other hand, when i tested Deep sleep, my device still advertised as well as had a higher voltage draw from the battery. I'm pretty flustered and lost... I am new to this, so please try to give me explanations if you can.
Thanks in advance for any help.
EDIT:
My BLE chip is part of a MESH system. When a message is received, the BLE chip goes from being a peripheral into a central role. The WDT is currently only being used to ensure that the BLE chip is in Central mode for a maximum of 4.5 seconds. So, I think I can replace this with a HFCLK timer. I see no reason to use the watchdog to be used for something like that - especially considering I can't have another Watchdog component with an interrupt ( I can't compile with 2 ).
Solved! Go to Solution.
- Labels:
-
PSoC 4 Architecture
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have created a project as per you requirement and try this at your end. Initially device enters into Deep Sleep mode for approx. 15 Seconds. Later, low power mode is exited and device scans for 3 Seconds which repeats further. Additionally, it also has control pin setup to receive a button press. Whenever the button is pressed it exit from deep sleep mode. During scanning you can see different Bluetooth devices in the Teraterm.
Let me know if this helps.
Thanks,
PSYU.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Andrew,
You can use WDT or GPIO interrupts to wake up from deepsleep. The below application note has details of different sleep modes for Psoc 4 device and wake up sources.
When the BLE is advertising or connected, the BLESS will wake up every advertising interval and connection interval and this will wake up the
MCU from deepsleep. To get more details on using BLE and low power modes please go through the below application note
Thanks,
Ranjith
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As far as I know, you can only have a single WTD with an interrupt? I have tried creating a new WTD w/ interrupt but I get an error from the IDE. If I upload my project, is there any chance you can look at it to make more specific suggestions? I am typically a mobile programmer and am extremely new to this. I'm trying to modify work of someone else that used to be on my team.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Each of the (3?) WDTs can interrupt and wakeup the processor from deep sleep I think.
Try looking at some of the WDT examples, as the wakeup/sleep/init code for those is fairly accurate/useful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have created a project as per you requirement and try this at your end. Initially device enters into Deep Sleep mode for approx. 15 Seconds. Later, low power mode is exited and device scans for 3 Seconds which repeats further. Additionally, it also has control pin setup to receive a button press. Whenever the button is pressed it exit from deep sleep mode. During scanning you can see different Bluetooth devices in the Teraterm.
Let me know if this helps.
Thanks,
PSYU.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! I will look at this tomorrow morning and let you know my thoughts!
UPDATE - Looks great for an example. I have to wonder though, was there a reason you selected 0x9u for the match on WDT1? You were trying to get as close to 15 seconds as possible (2 seconds for WDT0) + (9 counts on WDT1) = 18 seconds. Is this correct, or does the counter start at 1, so it would actually only be 16 seconds?
Also, If i wanted to go for 16 seconds, could I just use WDT2? I understand this is the 32 bit timer which can use interrupts as well. One of the configurations is set for 16 seconds. I ask because I would simply like to free up WDT0 and WDT1 so that I may use them later if I need to.
Thank you for everything!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
WDT0, WDT1 are 16 bit timers in order to achieve 15 seconds of time we require two timers and we have to cascade them. Whereas WDT2 is 32 bit timer and has fixed time period values for generating interrupts.
WDT2 is just enough to use for 16 seconds but it has fixed time period values for generating interrupts. These time period values are 500msec, 1sec, 2sec, 4sec, 8sec, 16sec, 32sec....etc. please see the image below. In WDT2 timer you can select desired time period values please refer the different period values in WDT2.
Thanks,
PSYU.