This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Multitasking Delays with STM32F103C8 (Non Blocking Delay)

Hello! I think this is the right place for my problems. I have been working with PIC Microcontrollers and CCS C compiler. I am very new to STM32 and Keil and things looked a bit weird to me just like a little boy that was transferred to a new school.

I write this code for my Blue Pill STM32F103C8.

The code which I posted below is actually working, the LED blinks with 500ms interval which is not blocking the loop. And when the Switch is closed the LED2 comes on after delaying 10,000ms (INTERVAL2). Then when the Switch is opened, the LED2 goes off without delay. The code does as I wanted but my worries is:

1. Is this approach just like Arduino millis() type of delay that gets roll over after about 49.7 days? If so, then how can I make this code work without problems?

2. Are there other better ways I can go around this in more reliability and efficiency?

Thanks.

Michael.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.c
* @brief : Main program body
******************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Delay
0