some stuff

This commit is contained in:
2022-01-28 14:00:31 -06:00
parent d94c63a964
commit 8dc484e0d1
49 changed files with 3511 additions and 664 deletions

28
labW6barnestr/Src/delay.c Normal file
View File

@@ -0,0 +1,28 @@
/*
* delay.c
*
* Created on: Dec 10, 2021
* Author: Trevor Barnes
*/
#include <inttypes.h>
#include "delay.h" //include declaration header file
void delay_1ms(uint32_t n){
// 1ms = 16,000 ticks
for (int i = n ; i > 0 ; i--) {
// Clear value register
*STK_VAL = 0x0000;
// Store 16,000 in STK_LOAD
*STK_LOAD = 16000;
// Enable clock, no prescaler, no interrupt
*STK_CTRL |= CLKSOURCE;
*STK_CTRL |= EN;
// Loop n times: Wait for countflag high
int flag;
do {
flag = ((*STK_CTRL & (1<<16))>>16);
} while (flag != 1);
}
}