From 0ff718e7cd7159c30636aa323a666ac1af684f63 Mon Sep 17 00:00:00 2001 From: sowgro Date: Sun, 31 Aug 2025 13:25:35 -0400 Subject: Setup project --- project/Core/Src/adc_dac_demo.c | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 project/Core/Src/adc_dac_demo.c (limited to 'project/Core/Src/adc_dac_demo.c') diff --git a/project/Core/Src/adc_dac_demo.c b/project/Core/Src/adc_dac_demo.c new file mode 100644 index 0000000..5deff83 --- /dev/null +++ b/project/Core/Src/adc_dac_demo.c @@ -0,0 +1,48 @@ +/* + * adc_example.c + * + * Created on: Apr 13, 2022 + * Author: bruce + */ + +#include "adc.h" +#include "dac.h" +#include "adc_demo.h" + +uint8_t one_second_elapsed = FALSE; +uint32_t counter = 0; + +/*** + * Demo uses the ADC to read the values set by the DAC. + * + * For the project, you will not use the ADC. +*/ +void run_adc_dac_demo() +{ + uint16_t counter = 0; + // printf ("Start!\n\r"); + init_systick(); + DAC_Init (); + ADC_Init (); + + DAC_Start (); + + uint32_t adc_value = 0; + + while (1) + { + if (one_second_elapsed /*&& (old_adc_value != new_adc_value)*/) { + ADC_Start (); + adc_value = ADC_Read_Value_Blocking (); + // printf ("ADC read: 0x%x\n\r", (unsigned int)adc_value); + // Rediculous way to eliminate warning. Delete this line when printf is working. + adc_value = adc_value; + + // Let power count up in a cycle. This is to make reading it more interesting. + DAC_Set_Value ((counter) % 0x1000); + counter++; + } + + } +} + -- cgit v1.2.3