From e2ba305068f3045944789bf65e29fb2f2f557879 Mon Sep 17 00:00:00 2001 From: sowgro Date: Wed, 1 Oct 2025 23:38:18 -0400 Subject: complete homework 4 --- project/Core/Src/demo.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'project/Core/Src/demo.c') diff --git a/project/Core/Src/demo.c b/project/Core/Src/demo.c index d34b7e3..fed34e3 100644 --- a/project/Core/Src/demo.c +++ b/project/Core/Src/demo.c @@ -15,15 +15,16 @@ #include "UART.h" #include "demo.h" #include "stm32l4xx.h" +#include "systick.h" // This function is to create a delay by consuming CPU cycle on counter -static void delay_loop( int value ) -{ - // spin loop consuming CPU to spend time. - for (int i = 0; i < value; i++) - ; -} +//static void delay_loop( int value ) +//{ +// // spin loop consuming CPU to spend time. +// for (int i = 0; i < value; i++) +// ; +//} // This function is to print counter on UART port and toggle LED static void demo_of_UART_print(int counter){ @@ -33,8 +34,10 @@ static void demo_of_UART_print(int counter){ n = sprintf((char *)buffer, "counter = %d\r\n", counter); USART_Write(USART2, buffer, n); - delay_loop( 8000000 ) ; // comment this out when you are ready to test delay_systick - // delay_systick() ; // enable this when you are ready to test + // delay_loop( 8000000 ) ; // comment this out when you are ready to test delay_systick + init_systick(); + delay_systick(); // enable this when you are ready to test + delay_systick(); // Toggle LED LED_Toggle(); -- cgit v1.2.3