What to remember when developing a program for STM32?
There are some things you should remember when you decide to use an STM32 and the STM32-Library. Please read also this: Two Words Concerning STM32 Library Initialize the structure that refer the peripherals that you need to use Configure correctly the I/O for use the peripherals Clock the peripherals
What is the system clock in f103c8?
In F103C8, there are 2 peripheral clocks i.e APB1 and APB2. In this tutorial I have decided to use the Timer 2, which is basically connected to the APB2. We know by now that our system clock is at 72 MHz, and the rest of the clock setup will be as shown below
When is the UIF bit set in STM32F103?
UIF Bit is set whenever there is update event. So we will wait until this bit is set while (!(TIM2->SR & (1<<0))); // UIF: Update interrupt flag.. This bit is set by hardware when the registers are updated
What do I need to enable the gpioc clock?
To enable the GPIOC clock, we need to modify the APB2 Enable Register (RCC_APB2ENR) As you can see in the picture above, the 4th bit of RCC_APB2ENR controls the GPIOC Clock.
How does the RTC work on a microcontroller?
This allows the main circuitry on the board, including the microcontroller to be completely powered down, and the RTC will keep running. The communication between the microcontroller and the RTC chip will generally be over a serial interface such as I²C or SPI.
Why is 32 kHz crystal used for RTC?
As mentioned in another answer, the 32 kHz crystal is used because it is convenient to divide down, the circuitry uses less power than higher frequency crystals, and it is very cheap since they are used in watches. A RTC is used to keep accurate time, and date. It transfers the programmed date to and from the IC.
What is the function of a RTC chip?
Some RTC chips have a ability to set alarms, and then interrupt the microcontroller when the alarm goes off. These are sometimes referred to as RTCC (Real-time clock/calendar) chips.