Hai
I wrote the code for ADC.I have a small doubt with ISR. I connected the potentio meter on port E pin3 .If i vary the potentio meter then my ADC value should be increase or decrease.Here i wrote the code in interrupt mechanism.
Every time i am waiting in the interrupt handler for complete the ADC converstion.But here the problem is even i vary the potentio meter , it is always in while loop only it is not going to the interrupt handler.please help is any thing i written wrong here.......................i did check the values of s&count these values are not changed.
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "driverlib/adc.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/rom.h"
void ADCIntHandler(void);
uint32_t pui32ADC0Value[5];
char *z;
int count1=0,data,s;
int
main(void)
{
ROM_FPULazyStackingEnable();
//
// Set the clocking to run directly from the crystal.
//
/*ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);*/
/**************************ADC configuration***************************************************/
SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);
ADCIntClear(ADC0_BASE, 3);
ADCIntEnable(ADC0_BASE, 3);
ROM_IntMasterEnable();
while(1)
{
ADCProcessorTrigger(ADC0_BASE, 3);
SysCtlDelay(SysCtlClockGet() / 10 / 3);
SysCtlDelay(SysCtlClockGet() / 10 / 3);
SysCtlDelay(SysCtlClockGet() / 10 / 3);
SysCtlDelay(SysCtlClockGet() / 10 / 3);
}
}
void
ADCIntHandler(void)
{
++count1;
ADCIntClear(ADC0_BASE, 3); // Clear the ADC interrupt flag.
while(!ADCIntStatus(ADC0_BASE, 3, false)) // Wait for conversion to be completed.
{
}
s=ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value);// // Read ADC Value.
data=pui32ADC0Value[0];
//return *z;
//SysCtlDelay(SysCtlClockGet() / 10 / 3);
// SysCtlDelay(SysCtlClockGet() / 10 / 3);
}