UMSAE-Formula-Electric / SCU

Sensor Control Unit
0 stars 0 forks source link

Implement RTC Module #32

Closed Sedkian closed 8 months ago

Sedkian commented 9 months ago

Implementing the RTC module will allow us to have timestamps on the SCU which is critical for data logging, collection, and studying.

We can any of the LSI, LSE, or HSE as a clock source to the RTC module.

LSI (Low Speed Internal) and LSE (Low Speed External) are two types of clocks available on the STM32 microcontroller.

LSI clock is generated internally by an RC oscillator circuit and its frequency is typically around 40kHz. This clock is suitable for low power applications and can be used as a reference clock for timers and watchdogs.

LSE clock, on the other hand, is generated externally by a crystal oscillator or an external resonator. Its frequency ranges from 32kHz to 50kHz and it provides higher accuracy than LSI clock. LSE clock is typically used as a clock source for the RTC (Real-Time Clock) module.

We can use the LSI clock as a clock source for the RTC module on some STM32 microcontrollers (STM32F446RE can). However, the accuracy of the RTC will be lower compared to using the LSE clock, as the LSI clock has a frequency tolerance of +/- 5% and a temperature drift of up to +/- 50 ppm, while the LSE clock has a frequency tolerance of +/- 0.5% and a temperature drift of up to +/- 20 ppm.

Sedkian commented 9 months ago

Implementing the RTC on an already developed project like the SCU could be a tough task. That's why I will start with trying the LSI as a clock source first and see how it goes.

Sedkian commented 9 months ago

I have got the RTC working properly and integrated into the SCU using LSI. Also, the clock frequency on the microcontroller is not affected! I am only working on SCU #34 and will open an MR with both of the fixes together.