cancel
Showing results for 
Search instead for 
Did you mean: 

DigitalClock STM32F746G-Disco

idrissmc
Associate III

hi everyone,

I want to make the digital clock work, how can I do that?

1 REPLY 1
O. Mz. - 7
Associate III

I use this code to display time and date. It works. In the Pinout&Configuration the "Activate Clock Source" and "Activate Calendar" are checked in the "Timers" section.

It just displays the time and the date on the OLED screen. The board is Nucleo F767ZI. Connecting the OLED is a separate topic, but your STM32F746G-Disco has the inbuilt display.

                RTC_TimeTypeDef stimestructureget;
 
		RTC_DateTypeDef sdatestructureget;
 
		HAL_RTC_GetTime(&hrtc, &stimestructureget, RTC_FORMAT_BIN);
		HAL_RTC_GetDate(&hrtc, &sdatestructureget, RTC_FORMAT_BIN);
 
		char timeBuff[12] = "";
		char dateBuff[16] = "";
 
		sprintf(timeBuff, "%u:%u:%u", stimestructureget.Hours,
				stimestructureget.Minutes, stimestructureget.Seconds);
 
		sprintf(dateBuff, "%u.%u.%u", sdatestructureget.Date,
				sdatestructureget.Month, 2000 + sdatestructureget.Year);
                
                //displaying time and date on the OLED screen
		SSD1306_GotoXY(0, 50); // x, y
 
		strcat(timeBuff, " ");
 
		strcat(timeBuff, dateBuff);
 
		SSD1306_Puts(timeBuff, &Font_7x10, 1);
 
		SSD1306_UpdateScreen(); // update screen