2020-10-15 10:51 AM
Hi All,
This is my first MCU project attempt and figured I would build a 7-segment clock. I have managed to write a little bit of code to configure the GPIOs in the way that I want them as well as the system clock, but I cannot for the life of me figure out how to get the RTC up and running (after reading the notes in the source file). I seem to have slammed into a wall at the RTC_Init stage.
My current system clock setup is this:
void clk_setup (void){
//Disable the CLK, ready for setup
CLK_DeInit;
//Set Hi-Speed Internal to On
CLK_HSICmd(ENABLE);
//Set Hi-Speed External to off
CLK_HSEConfig(CLK_HSE_OFF);
//Set Lo-Speed Internal to on
CLK_LSICmd(ENABLE);
//Wait for Busy flag to go low
while(CLK_GetFlagStatus(CLK_FLAG_LSIRDY) == FALSE);
//Set Lo-Speed External to ON 32,768Khz
CLK_LSEConfig(CLK_LSE_ON);
//Wait for Lo-speed external busy flag to go low
while(CLK_GetFlagStatus(CLK_FLAG_LSERDY) == FALSE);
//Set System Clock to Hi-Speed-internal
CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI);
//Set System clock Divider to 8
CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_8);
//Set RTC Clock to Lo-speed-external.
//Set RTC Clock divider to 1
CLK_RTCClockConfig(CLK_RTCCLKSource_LSE, CLK_RTCCLKDiv_1);
//Set RTC Clock Peripheral to Enable
CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);
//Set LSE CSS to on
CLK_LSEClockSecuritySystemEnable;
//Set RTC Failure mode to on
CLK_RTCCLKSwitchOnLSEFailureEnable;
//Set configurable clock output to off
CLK_CCOConfig(CLK_CCOSource_Off, CLK_CCODiv_1);
//Turn on UART clock
CLK_PeripheralClockConfig(CLK_Peripheral_USART1, ENABLE);
//Turn on ADC clock
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
}
Any help with the getting the RTC up and running is appreciated, though bare in mind, I am completely new to this programming lark :beaming_face_with_smiling_eyes: , My last clock was all 4000 series logic :face_with_tears_of_joy:
Cheers
John