Putting STM32F103 in sleep mode

General discussion on mikroElektronika website & forums.
Post Reply
Author
Message
035uros
Posts: 1
Joined: 09 Jul 2023 12:58

Putting STM32F103 in sleep mode

#1 Post by 035uros » 09 Jul 2023 13:04

Hello,

I am working on STM32F103C8T8 project. I am using MikroC as an environment.
I would like to put stm in a sleep mode and wake it up using external interrupt (UART interrupt). There is no much info online, most of it says to use some WFI (wait for interrupt) function but I don't think MikroC have it?

Does anybody had similar situation and is there any solutions?

Thank you and best regards,
Uros M.

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: Putting STM32F103 in sleep mode

#2 Post by IvanJeremic » 12 Jul 2023 08:30

Hi,

You can see how we use Interrupts in our interrupt examples in MikroC PRO compilers in the Project Explorer.

I have attached it here as well, but there are more that you can take a look at in the compiler:
External Interrupt.zip
(57.02 KiB) Downloaded 22 times
You can find more about the Sleep mode in the datasheet of your MCU:
https://www.st.com/resource/en/datashee ... f103c8.pdf

Regards,

Ivan.

zhschip
Posts: 4
Joined: 24 Jan 2024 10:07

Re: Putting STM32F103 in sleep mode

#3 Post by zhschip » 11 Mar 2024 09:42

When working on a project involving the STM32F103C8T6 microcontroller and MikroC environment to implement sleep mode and wake-up using an external interrupt like a UART interrupt, there are alternative approaches you can consider if functions like WFI (Wait For Interrupt) are not readily available in the MikroC compiler.

Here are some suggestions to help you achieve your goal:

1、Low-Power Modes:

Check if MikroC provides functions or libraries to directly support low-power modes like Sleep Mode or Stop Mode on the STM32F1 series microcontrollers. These modes typically involve disabling unnecessary peripherals and entering low-power states.

2、Custom Interrupt Handling:

Instead of relying on WFI directly, you can implement custom interrupt handling routines for the UART interrupt. This involves configuring the external interrupt (UART interrupt) and setting up the microcontroller to wake up from sleep when that interrupt occurs.

3、Manual Sleep Mode Implementation:

You can manually implement a sleep mode by disabling unnecessary peripherals, entering a low-power state, and then configuring the UART interrupt as a wake-up source. This approach involves toggling the microcontroller's sleep mode by adjusting registers directly.

4、External Libraries or Examples:

Look for external libraries or example codes that provide low-power functionalities for the STM32F1 series. These might offer pre-implemented functions to simplify the process of putting the microcontroller to sleep and waking it up using interrupts.

5、Consulting MikroC Support or Forums:

Reach out to the MikroC support team or forums to inquire about low-power modes and interrupt handling specifics for the STM32F1 series. They might provide insights, code snippets, or guidance tailored to your specific platform and requirements.

6、Manual Assembly Level Coding:

As a last resort, you can consider writing low-level, assembly-coded sleep and wake-up routines if the MikroC compiler lacks the necessary high-level functions for power management and interrupt handling.
By exploring these options, you should be able to find a suitable solution for implementing sleep mode and waking up the STM32F103C8T6 microcontroller using an external UART interrupt within the MikroC development environment.
Zhonghaisheng provides original electronic components with low prices, fast delivery,excellent after sales service.with huge selection in stock and ready to ship same day with no minimum orders.New electronic components and parts added every day.

Post Reply

Return to “Website & Forums General Discussion”