Timer and Interrupt used together to leave sleep mode

Maple Mini, Maple Rev3, Maple Rev 5 and Maple Ret 6, iTead Maple etc
Leonardo_evaldt
Posts: 19
Joined: Wed Jul 19, 2017 3:30 pm

Timer and Interrupt used together to leave sleep mode

Post by Leonardo_evaldt » Thu Sep 14, 2017 6:35 am

Hi Guys.

Anyone here knows a site or link that show the code to put maple mini on SLEEP MODE? I want to put the board on sleep mode with two different ways to leave it: By a counter or by an interrupt pin.

I found the official documento about sleep modes on ST site, but... I am no an expert in register programmer. I was wondering if anyone knows something "less difficult" to non-professional user, like a library?

Thanks all.
Last edited by Leonardo_evaldt on Thu Sep 14, 2017 10:36 pm, edited 1 time in total.

victor_pv
Posts: 1601
Joined: Mon Apr 27, 2015 12:12 pm

Re: MAPLE MINI - SLEEP MODE

Post by victor_pv » Thu Sep 14, 2017 1:02 pm

There are multiple posts in the forum about that. Please do a search for sleep and standby.
If you don't have a more specific question I'll lock this thread since a search will answer it. If you have a more specific question, please update the first post and it's title after you search for what's available already.

Forum rules and procedures

Leonardo_evaldt
Posts: 19
Joined: Wed Jul 19, 2017 3:30 pm

Timer and Interrupt used together to leave sleep mode

Post by Leonardo_evaldt » Thu Sep 14, 2017 6:04 pm

Dear Victor,

There is a lot of posts related. But none of then answering my question or give me the anwser I need.
As I said, I'm not a professional firmware engineer. I don't understand 90% of they say. My question is if someone knows about a finished library that I can use. There is a lot of posts about this but to arduino. I tried to compile some but my processor not acceptd.
So I appreciate if you keep this post because I realy need this anwser.

Best regards.
Last edited by Leonardo_evaldt on Thu Sep 14, 2017 10:37 pm, edited 1 time in total.

victor_pv
Posts: 1601
Joined: Mon Apr 27, 2015 12:12 pm

Re: MAPLE MINI - SLEEP MODE

Post by victor_pv » Thu Sep 14, 2017 7:32 pm

Leonardo, I found a link to a library in less than 3 minutes. You are basically asking for someone else to do a search for you.

Leonardo_evaldt
Posts: 19
Joined: Wed Jul 19, 2017 3:30 pm

Timer and Interrupt used together to leave sleep mode

Post by Leonardo_evaldt » Thu Sep 14, 2017 9:19 pm

Victor,

Again, all topics I found didnt anwser my question. I need a topic who provide me a library that give me the option of put maple mini in sleep mode with two ways to leave it: By a interrupt OR by a timer. BOTH AT THE SAME CODE.
Perhaps you are talking about this topic

http://www.stm32duino.com/viewtopic.php ... eep#p29094

where the member "ag123" give a link to a code that (I think, but I do not have sure) create a timer clock attached to system clock and enable interrupts (again, I am not a professional firmware engineer, so I don't understand all the code). Not helps me.

Or perheps you are talking about this topic

http://www.stm32duino.com/viewtopic.php ... ilit=sleep

Where ag123 give a lot of other codes related sleep mode and timer clocks. But none of them solve my problem.
I'm not this lazy guy that you are suggesting. I have not treated anyone like this here in this forum, so I would be grateful if you did not treat me with so little respect.

After some hours of hunting up on internet I found this document in other forums website.

http://www.st.com/content/ccc/resource/ ... 228163.pdf

This document explains, in a very didactic way, about energy management in topic 2.5.1. I'm still reading it. But I still ask you to do not delete or block this post because i don't know if the document will really solve my problem.

Thanks for understanding.
Last edited by Leonardo_evaldt on Thu Sep 14, 2017 10:37 pm, edited 1 time in total.

victor_pv
Posts: 1601
Joined: Mon Apr 27, 2015 12:12 pm

Re: MAPLE MINI - SLEEP MODE

Post by victor_pv » Thu Sep 14, 2017 9:32 pm

Did you see this one?
http://www.stm32duino.com/viewtopic.php ... ep+library

That topic is one of the first ones I get in a search for "sleep library".

You also need to read the STM32F103 datasheet, because you need to understand how and what can wake up the CPU. You dont need any library to wake it up, just enable whatever interrupt or event you want to use to wake it up, then go to sleep with wfi or wfe. The libraries are about disabling certain peripherals or clocks before going to sleep.
Please update your thread title and first post to be more specific.
"MAPLE MINI - SLEEP MODE" is anything but specific and goes against the rules.

Leonardo_evaldt
Posts: 19
Joined: Wed Jul 19, 2017 3:30 pm

Timer and Interrupt used together to leave sleep mode

Post by Leonardo_evaldt » Thu Sep 14, 2017 10:35 pm

Yes I did.
Acobo used this strange function “adc_disable_all();” to disable the ADC and this one setGPIOModeToAllPins(GPIO_INPUT_ANALOG) to disable the GPIO. I didn’t understand exactly how this functions works but, in my case, I cant use the first one. My interrupt uses the ADC to wake up.

After a lot of hardware discuss, acobo show a list of functions to disable all blocks inside the processor. But the ADC interrupt will be disabled too. It doesn't solve my problem. I need to enable interrupt to wake up my board too. Just letting ADC enable (rcc_clk_enable(RCC_ADC1)) doesn't mean that the interrupt attached to it will make my board wake up when an interrupt occurs because sleepAndWakeUp function just finish when the alarmDelay finish.
Adapting my original question to this situation, it would look like this: “How can I use this WFI function together with sleepAndWakeUp function so my board could be able to wake up after a predetermined time OR an interrupt”?
In my first post I ask for a library because I thought that someone could have a code that put together WFI and sleepAndWakeUp.

About the title of the topic, I am sorry about It. As I did not see any post with this title especific to maple mini, I understood that it would be a good title for other members understand that the topic gave an alternative of how to put the board in sleep mode. I changed it. Now does that according to the rules???

victor_pv
Posts: 1601
Joined: Mon Apr 27, 2015 12:12 pm

Re: Timer and Interrupt used together to leave sleep mode

Post by victor_pv » Thu Sep 14, 2017 11:00 pm

The title makes more sense now, "Maple and sleep" is just extremely wide.
I still not understanding exactly how you want to wake up. You say you want a pin interrupt to wake the MCU, to me that means a pin toggling from high to low or from low to high, that's an EXTI interrupt, but you mention ADC. Are you wanting to wake up when an analog input gets to a certain analog level?

Leonardo_evaldt
Posts: 19
Joined: Wed Jul 19, 2017 3:30 pm

Re: Timer and Interrupt used together to leave sleep mode

Post by Leonardo_evaldt » Thu Sep 14, 2017 11:22 pm

victor_pv wrote:
Thu Sep 14, 2017 11:00 pm
The title makes more sense now, "Maple and sleep" is just extremely wide.
Nice :D. Thank you for this help. I'm new here. I'm still learning.
victor_pv wrote:
Thu Sep 14, 2017 11:00 pm
I still not understanding exactly how you want to wake up. You say you want a pin interrupt to wake the MCU, to me that means a pin toggling from high to low or from low to high, that's an EXTI interrupt, but you mention ADC. Are you wanting to wake up when an analog input gets to a certain analog level?
Something like this. The interrupt is attached in a digital pin. But I use the ADC and some Transistors to allow the signal fire the digital pin interrupt. So, my ADC needs to be working.
I think that, using that "acobo' disable list (but without rcc_clk_disable(RCC_ADC1) I can solve the problem about ADC. But the problem is, how to use sleepAndWakeUp function with interrupt enabled? Because, as I understood, sleepAndWakeUp just wake up the bord when timer finish and WFI only wake up the board when an iterrupt fire the digital pin. I need both wake up ways in the same function.

victor_pv
Posts: 1601
Joined: Mon Apr 27, 2015 12:12 pm

Re: Timer and Interrupt used together to leave sleep mode

Post by victor_pv » Fri Sep 15, 2017 12:21 am

Read the code of sleepAndWakeUp() because it shows what it does, and any enabled interrupt can wake the board.
I still do not understand what you are doing with the ADC...

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest