Hello I am using Stellaris lm3s3748 and all i want is to read a signal from the ADC0 and after the conversion i wanna write the output to GPIO PA0 as digital output i wrote the code but am not sure that its the correct way i want someone to help me if there any issue in my code
this is my code
#include "hw_types.h"
#include "hw_memmap.h"
#include "driverlib/adc.h"
#include "inc/lm3s3748.h"
#include <stdio.h>
#include "driverlib/gpio.h"
#include "hw_types.h"
#include "hw_ints.h"
#include "driverlib/sysctl.h"
#include "utils/ustdlib.h"
void main()
{
//
//
//Turn ADC module ON
//
//
SYSCTL_RCGC0_R |= SYSCTL_RCGC0_ADC;
//
//Sampling frequency set 500ksps
//
SYSCTL_RCGC0_R |= SYSCTL_RCGC0_ADCSPD500K;
//
// Disable the ADC for safe modification
//
ADC_ACTSS_R &= ~(ADC_ACTSS_ASEN0);
while(1){
//
//
//if there is any ADC process, give the priority to Sample sequencer 0 (the sequencer that I use) --optional
//
ADC_SSPRI_R = (ADC_SSPRI_SS0_1ST);
//
//
// ADC module trigger is the processor
//
ADC_EMUX_R = (ADC_EMUX_EM0_PROCESSOR);
//
//
//Configure pin ADC0 as an input
//
//
ADC_SSMUX0_R = ((0 << ADC_SSMUX0_MUX0_S));
//
// Retrieve data from sample sequence 0 FIFO invariable X1
//
//
int x1 = ADC_SSFIFO0_R;
//enable GPIO portA
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//Configure pin PA0 as an output
GPIODirModeSet(GPIO_PORTA_BASE, 0x01, GPIO_DIR_MODE_OUT);
//write variable x1 to pin PA0
GPIOPinWrite(GPIO_PORTA_BASE, 0x01, x1);
}
}
thanks in advance