This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

using Stellaris ADC and GPIO

Other Parts Discussed in Thread: LM3S3748

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()
{

//
// Enable the clock to the ADC module
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC);

//
// Configure the ADC to sample at 500KSps
//
SYSCTL_RCGC0_R |= SYSCTL_RCGC0_ADCSPD500K;


//
// Disable sample sequences 0
//
ADCSequenceDisable(ADC_BASE, 0);

//
// Configure sample sequence 0 step 0
//
ADCSequenceStepConfigure(ADC_BASE, 0, 0, ADC_CTL_CH0);

//
// Retrieve data from sample sequence 0 FIFO
//
unsigned long x1;
while(1){
ADCSequenceDataGet(ADC_BASE, 0, &x1);

//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
unsigned char y = x1;
GPIOPinWrite(GPIO_PORTA_BASE, 0x01, y);

}
}

Thanks in Advanve