Hi Amit,
Can you please tell me how to change sample time of the ADC in TM4C123GH6PM. In the data sheet sample time is given as 250ns. I need increase Sample time. Here is my working code of ADC. Please tell me how to change sample time in this code.
#include"inc/tm4c123gh6pm.h"
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/sysctl.h"
#include "driverlib/adc.h"
#include "driverlib/rom.h"
#define MAX_CHANNEL_NUMBER 0x18
unsigned char Temp_ADC_channel_number;
unsigned int ADC_result_value = 0x0000;
unsigned int ADC_Result_Buffer_Value[4];
void System_Clock_Set(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);//Sets the clocking of the device
}
unsigned int ADC_TM4C123G6_Convert_Channel (unsigned char ADC_Current_Channel_Number)
{
Temp_ADC_channel_number = ADC_Current_Channel_Number ;
System_Clock_Set();
if ( (Temp_ADC_channel_number >= MAX_CHANNEL_NUMBER) )
{
return (ADC_result_value);
}
else
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);//Enables a peripheral.
ADCHardwareOversampleConfigure(ADC1_BASE, 64);//Configures the hardware oversampling factor of the ADC.
ADCSequenceConfigure(ADC1_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);//Configures the trigger source and priority of a sample sequence.
ADCSequenceStepConfigure(ADC1_BASE, 1, 0, Temp_ADC_channel_number);//Configure a step 0 of the sample sequencer.
ADCSequenceStepConfigure(ADC1_BASE, 1, 1, Temp_ADC_channel_number);//Configure a step 1 of the sample sequencer.
ADCSequenceStepConfigure(ADC1_BASE, 1, 2, Temp_ADC_channel_number);//Configure a step 2 of the sample sequencer.
ADCSequenceStepConfigure(ADC1_BASE,1,3,Temp_ADC_channel_number|ADC_CTL_IE|ADC_CTL_END);//Configure a step 3 of the sample sequencer.
ADCSequenceEnable(ADC1_BASE, 1);//Enables a sample sequence.
ADCIntClear(ADC1_BASE, 1);//Clears sample sequence interrupt source.
ADCProcessorTrigger(ADC1_BASE, 1);//Causes a processor trigger for a sample sequence.
while(!ADCIntStatus(ADC1_BASE, 1, false))//Gets the current interrupt status.
{
}
ADCSequenceDataGet(ADC1_BASE, 1, ADC_Result_Buffer_Value);//Gets the captured data for a sample sequence.
ADC_result_value = (ADC_Result_Buffer_Value[0] + ADC_Result_Buffer_Value[1] + ADC_Result_Buffer_Value[2] + ADC_Result_Buffer_Value[3] + 2)/4;
return ADC_result_value;
}
}
Regards,
Mamatha