Skip to content

Commit

Permalink
ADC_Init_Potentiometer #4
Browse files Browse the repository at this point in the history
  • Loading branch information
HaidySamir1696 committed May 3, 2019
1 parent a39ee1c commit 3d1ecdc
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Tivac2/adc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "adc.h"


void ADC0_SS3_Init (void)
{
SYSCTL_RCGCADC_R |= (1<<0); //enable ADC0 clock
ADC0_ACTSS_R &= ~(1<<SS_num); //disable sample sequncer during configuration
ADC0_EMUX_R = (ADC0_EMUX_R& ~(0xF<<SS_num*4)) | (trigger_select<<SS_num*4) ; //choosing the triggering method
ADC0_SSMUX3_R = 0x0; //input from channel 0 i.e PE3
ADC0_SSCTL3_R |= ( (ADC0_SSCTL3_TS0<<3) | (ADC0_SSCTL3_IE0<<2) | (ADC0_SSCTL3_END0<<1)); //configuring sample sequncer 3 control port
if(ADC0_SSCTL3_IE0 == 0x1)
{
ADC0_IM_R |= (1<<3);
NVIC_EN0_R |= (1<<17);
}
ADC0_ACTSS_R |= (1<<SS_num); //enable sample sequncer during configuration
}
void ADC_Init_Potentiometer (void)
{
ADC0_SS3_Init ();
Port_AnalogOrDigital (PORTE, 0X08, 0);
//Port_AlternateFunction (PORTE,0X08,1, uint32_t pctl_mask);
GPIO_PORTE_AFSEL_R|=0x08;


}
43 changes: 43 additions & 0 deletions Tivac2/adc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

#ifndef ADC_H_
#define ADC_H_

#include "port.h"
#include "DIO.h"
#include "tm4c123gh6pm.h"
#include "std_types.h"

#ifndef PORTA
#define PORTA 0
#endif

#ifndef PORTB
#define PORTB 1
#endif

#ifndef PORTC
#define PORTC 2
#endif

#ifndef PORTD
#define PORTD 3
#endif

#ifndef PORTE
#define PORTE 4
#endif

#ifndef PORTF
#define PORTF 5
#endif

#define trigger_select 0x0F
#define SS_num 3
#define ADC0_SSCTL3_IE0 0x1
#define ADC0_SSCTL3_END0 0x1
#define ADC0_SSCTL3_TS0 0x1


void ADC0_SS3_Init (void);

#endif

0 comments on commit 3d1ecdc

Please sign in to comment.