summaryrefslogtreecommitdiff
path: root/project/Core/Src/Activties/activity6.c
blob: 53f8bb0528a5b2dd8af5d3a2c84af4501084bdb8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * activity6.c
 *
 *  Created on: Sep 25, 2025
 *      Author: sowgro
 */

#include <stdint.h>
#include <stdio.h>

typedef struct {
	uint32_t CSR;
	uint32_t RVR;
	uint32_t CVR;
	uint32_t CALIB;
} sys_tick;


void activity6_run() {
	sys_tick *s = (sys_tick *) 0xE000E010;
	printf("%lu\r\n", s->CVR);

	s->RVR = 8000000;
	s->CSR |= 1;      // Turn on systick timer
	s->CSR |= 1<<2;   // Use internal clock

	int time = 0;
	int count = 0;
	for(;;) {
        if (s->CSR & (1<<16)) {
            count++;
            if (count == 10) { // Count to 10 tenths then print next second
                printf ("%d\r\n", time);
                time++;
                count = 0;
            }

        }
	}
}