blob: a4dad21568f0d30fd535f14843c294de51c9101a (
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
|
/*
* activity13.c
*
* Created on: Nov 18, 2025
* Author: sowgro
*/
#include <stdint.h>
#include <stdio.h>
#include "systick.h"
#include "tone.h"
#include "dac.h"
//write 1s for half the freq and 0s for the other half
void play_freq(uint16_t hz) {
uint32_t rollover = hertz_to_systicks (hz);
if ((systick_get_count () % rollover) < (rollover >> 1)) {
DAC_Set_Value(500);
// printf ("1");
}
else {
DAC_Set_Value(0);
// printf ("0");
}
}
void activity13_run() {
init_systick();
DAC_Init();
DAC_Start();
for(;;) {
play_freq(500);
}
// DAC_Set_Value(3000);
}
|