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.

Regarding interrupt controller

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);

}

  • can i write the ADC code in polling method and how?please guide me

  • Hi,
    Things to take into account when using interrupts:
    a) before configuring something for a particular ADC sequencer, disable it first, do the configurations and then enable that sequenceer;
    b) enabling interrupts should be done as follows:
    - in startup_ccs.c file (if you use CCS) add at the beginning of the file the statement
    extern void ADCHandler(void);
    and into interrupts vector insert the word ADCHandler instead DefIntHandler;
    - in your main file enable NVIC interrupt bit for ADC, by using this statement:
    IntEnable(INT_ADC0SS3); // see the comments/docs about this in driverlib/interrupts.c; the parameter INT_ADC0SS3 is defined in inc/hw_ints.h .

    Note your interrupt handler does not need to wait for conversion completion since at the interrupt time the conversion is already done.

    Petrei

  • thank u petri to gave me that suggestion.Now i got the result thank u once again.