Close

Counting Ticks, Making Time

A project log for NTP Clock Based on STM32H735 Discovery Kit

This is an SNTP clock based on the STM32H735 Discovery Kit.

dmoisandmoisan 04/01/2021 at 21:310 Comments

If you're just joining in, this is a project log about making an NTP clock from ST Microelectronics' STM32H735G Discovery Kit. In our last entry, I created a timer that calls a function once a second.  This function would update a seconds counter and display the time.  Here it is, in ntpdisplaytasks.c

extern void DisplayUpdate() {
	// Turn on LED
	BSP_LED_On(LED1);
	DisplayClock(SecondsCounter, TimeZoneName, TimeZoneOffset, DSTFlag);

	//
	// Increment seconds counter.
	//

	SecondsCounter++;

	//
	// Turn off LED1
	//
	const TickType_t xDelay = 50 / portTICK_PERIOD_MS; // 50 ms delay before turning the LED of
	vTaskDelay(xDelay);

	BSP_LED_Off(LED1);

 Remember that the Discovery Kit has two LED's available, one green, one red.  I used the red one during startup to indicate problems and lockups.  The green LED is our time tick.  It blinks once a second,  It's turned on before we call DisplayClock, and turned off afterwards.  Before the LED is extinguished, though, I insert a 50 millisecond delay using vTaskDelay, which is a FreeRTOS function.  The actual blink period is a useful indication of how long it takes DisplayClock to run.  DisplayClock does all of the display work, and I'm worried about efficiency.

We also increment SecondsCounter.  This is the main counter by which we keep time.  The DisplayClock function also has provisions for specifying the timezone name and offset, and includes a daylight-savings/summer-time flag.  Presently, I don't implement these features;  the clock displays UTC only for the moment, just like my original Twatch clock.

My next entry will cover the calculation of time elements, hours, minutes, and seconds, from SecondsCounter.  This will be a long project entry, so it gets its own post.  Catch up with me then! 

Discussions