-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDAC.cpp
More file actions
25 lines (23 loc) · 656 Bytes
/
Copy pathDAC.cpp
File metadata and controls
25 lines (23 loc) · 656 Bytes
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
// put implementations for functions, explain how it works
// put your names here, date
#include <stdint.h>
#include "../inc/tm4c123gh6pm.h"
#include "DAC.h"
// **************DAC_Init*********************
// Initialize 6-bit DAC, called once
// Input: none
// Output: none
void DAC_Init(void){
SYSCTL_RCGCGPIO_R |= 0x02;
while(SYSCTL_RCGCGPIO_R == 0) {}
GPIO_PORTB_DIR_R |= 0x3F;
GPIO_PORTB_DEN_R |= 0x3F;
}
// **************DAC_Out*********************
// output to DAC
// Input: 6-bit data, 0 to 18
// Input=n is converted to n*3.3V/18
// Output: none
void DAC_Out(unsigned char data){
GPIO_PORTB_DATA_R = data; //puts the data in the DAC
}