I'm using a C2000 LaunchPadXL withF28027 and the following code, which light up the leds 1&3 or 2&4 (GPIO 0/1/2/3), depending on the state of the onboard button (GPIO12). It also shows the CLK/4 at GPIO 18. This works fine, however why is the ISR not serviced in this case? What do I wrong?
//#############################################################################
// COMMENTS CLK/ADC/GPIO example
// example program with debug expressions
// button_pressed, loop_counter, isr_counter, Voltage_6
//#############################################################################
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
#include "f2802x_common/include/clk.h"
#include "f2802x_common/include/gpio.h"
#include "f2802x_common/include/pll.h"
#include "f2802x_common/include/wdog.h"
#include "f2802x_common/include/adc.h"
#include "f2802x_common/include/pie.h"
int button_pressed = 0;
long int loop_counter = 0;
long int isr_counter = 0;
uint_least16_t Voltage_6;
CLK_Handle myClk;
GPIO_Handle myGpio;
WDOG_Handle myWDog;
PLL_Handle myPll;
ADC_Handle myADC;
void main(void)
{
// Initialize all the handles needed for this application
myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj));
myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj));
myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj));
myADC = ADC_init((void *)ADC_BASE_ADDR, sizeof(ADC_Obj));
// Perform basic system initialization
WDOG_disable(myWDog);
//Select the internal oscillator 1 as the clock source
CLK_setOscSrc(myClk, CLK_OscSrc_Internal);
CLK_enableAdcClock(myClk);
// Setup the PLL for x10 /2 which will yield 10MHz * 12 / 2 = 60MHz
PLL_setup(myPll, PLL_Multiplier_12, PLL_DivideSelect_ClkIn_by_2);
// Initalize GPIO
GPIO_setDirection(myGpio, GPIO_Number_18, GPIO_Direction_Output);
GPIO_setMode(myGpio, GPIO_Number_18, GPIO_18_Mode_XCLKOUT); // SYSCLKOUT/4 op GPIO-18
GPIO_setPullUp(myGpio, GPIO_Number_12, GPIO_PullUp_Disable);
GPIO_setMode(myGpio, GPIO_Number_12, GPIO_12_Mode_GeneralPurpose); // onboard push button
GPIO_setDirection(myGpio, GPIO_Number_12, GPIO_Direction_Input);
GPIO_setPullUp(myGpio, GPIO_Number_0, GPIO_PullUp_Enable); // pull-up 20k on board led 1
GPIO_setMode(myGpio, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose);
GPIO_setDirection(myGpio, GPIO_Number_0, GPIO_Direction_Output);
GPIO_setPullUp(myGpio, GPIO_Number_1, GPIO_PullUp_Enable);
GPIO_setMode(myGpio, GPIO_Number_1, GPIO_0_Mode_GeneralPurpose);
GPIO_setDirection(myGpio, GPIO_Number_1, GPIO_Direction_Output);
GPIO_setPullUp(myGpio, GPIO_Number_2, GPIO_PullUp_Enable);
GPIO_setMode(myGpio, GPIO_Number_2, GPIO_0_Mode_GeneralPurpose);
GPIO_setDirection(myGpio, GPIO_Number_2, GPIO_Direction_Output);
GPIO_setPullUp(myGpio, GPIO_Number_3, GPIO_PullUp_Enable);
GPIO_setMode(myGpio, GPIO_Number_3, GPIO_0_Mode_GeneralPurpose);
GPIO_setDirection(myGpio, GPIO_Number_3, GPIO_Direction_Output);
// Initalize ADC
ADC_enableBandGap(myADC);
ADC_enableRefBuffers(myADC);
ADC_powerUp(myADC);
ADC_enable(myADC);
ADC_setVoltRefSrc(myADC, ADC_VoltageRefSrc_Int);
ADC_enableInt(myADC, ADC_IntNumber_6);
ADC_setIntMode(myADC, ADC_IntNumber_6, ADC_IntMode_ClearFlag); // EOC (End Of Conversion) or ClearFlag
while(1) // loop and wait for interrupt
{
if(GPIO_getData(myGpio, GPIO_Number_12) != 1) // board button GPIO_12 not pressed
{
GPIO_setHigh(myGpio, GPIO_Number_0); // led off (not pressed)
GPIO_setLow(myGpio, GPIO_Number_1);
GPIO_setHigh(myGpio, GPIO_Number_2);
GPIO_setLow(myGpio, GPIO_Number_3);
button_pressed = 0;
}
else
{
GPIO_setLow(myGpio, GPIO_Number_0); // led on (pressed)
GPIO_setHigh(myGpio, GPIO_Number_1);
GPIO_setLow(myGpio, GPIO_Number_2);
GPIO_setHigh(myGpio, GPIO_Number_3);
button_pressed = 1;
}
loop_counter++;
}
}
interrupt void adc_isr(void)
{
isr_counter++;
Voltage_6 = ADC_readResult(myADC, ADC_ResultNumber_6);
ADC_clearIntFlag(myADC, ADC_IntNumber_6); // Clear ADCINT6 flag reinitialize for next SOC (start of conversion)
return;
}
//===========================================================================
// No more.
//===========================================================================