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.

CCS/CC3200-LAUNCHXL: SysTick Interrupt not working as expected

Part Number: CC3200-LAUNCHXL
Other Parts Discussed in Thread: CC3200

Tool/software: Code Composer Studio

Hello,

I am writing a program to control an amplifier with a CC3200. I started from the udma example program with some input on the dma programming of the system ADCs from the smartplug program.

In short I have DMA interrupts from the ADC about every 8 ms and every 0.125 s I have a SysTick interrupt task (SysTickHandler) for led management and system survey/control operations.

The program run as I wanted until I decided to put a trap to catch a potential initialization error on my I2C thermometers, sending the sequence into an infinite loop and I was expecting the Systick interrupt to continue to operate blinking an LED to signal the condition, but this is not the case.

It does not matter whether I add the instruction SysTickIntEnable() or not: the code, including the blinking routine, work as expected except when I force the thermometer initialization error and then it stays in the infinite loop, but the Systick interrupt does not execute.

I am obviously missing something about Systick interrupts, but I have not found an answer in the documentation.

Thanks in advance for your help. I am attaching the relevant code below:

void
main()
{
unsigned long time; // elapsed time for interrupt
extern unsigned char Tbuffer;
extern unsigned char Tlength;
extern unsigned char adc_error; // error flags: offset and init
extern unsigned char adc_error_delay;
extern unsigned char aux_error;
extern unsigned char calibrate_2;
extern unsigned short center_scale;
unsigned short seconds_to_cal = 0;
int iRetVal;
time_flag_count = 0;
//
// Initializing the board
//
BoardInit();
//
// Muxing for Enabling UART_TX and UART_RX, and LEDs
//
//All LEDS and pins off here
//
PinMuxConfig();
GPIO_IF_LedConfigure(LED1|LED2|LED3); //board LED green, yellow and red (also FAN_PWM)
GPIO_IF_LedOff(MCU_ALL_LED_IND);
GPIO_IF_Set(EXT_RED_LED, GPIOA2_BASE, 0x1, 0);
GPIO_IF_Set(PWR_BUS, GPIOA2_BASE, 0x2, 0);
GPIO_IF_Set(SPKR_SWITCH, GPIOA3_BASE, 0x10, 0);
GPIO_IF_Set(EXT_YELLOW_LED, GPIOA0_BASE, 0x80, 0);
GPIO_IF_Set(EXT_BLUE_LED, GPIOA1_BASE, 0x40, 0);
GPIO_IF_Set(ADC_CAL, GPIOA0_BASE, 0x40, 0);
//
GPIO_IF_Set(ADC_CAL, GPIOA0_BASE, 0x40, 1); // Start by calibrating ADCs
//
// Initializing the Terminal.
//
InitTerm();
//
// I2C Init
//
I2C_IF_Open(I2C_MASTER_MODE_FST);
//
// Display Welcome Message
//
DisplayBanner();
//
// SysTick Enabling
//
SysTickIntRegister(SysTickHandler);
SysTickPeriodSet(SYSTICK_RELOAD_VALUE);
SysTickEnable();
SysTickIntEnable();
//
// Blink green_led
//
green_led = 1; //green led toggle
//
MAP_UtilsDelay(2666666); //Wait 0.2 s for supplies power up
//
//PWM fan drive
//
InitPWMModule();
//
iRetVal = Thermometer_Init();
//
if(iRetVal == FAILURE)
{
while(FOREVER) //Halt on thermometer init. failure
{
green_led = 1;
}
}
// Read voltages here
//
// Turn power bus on
//
GPIO_IF_Set(PWR_BUS, GPIOA2_BASE, 0x2, 1);
//turn calibration on
//
calibrate_2 = 1;
GPIO_IF_Set(ADC_CAL, GPIOA0_BASE, 0x40, 1); //set hardware to adc calibration
//
// uDMA Initialization for ADCs
//
UDMAInit();
//
UART_PRINT("Completed DMA Initialization \n\r\n\r");
//
// Ping Pong UART Transfer
//
InitADC2Transfer();
//
UART_PRINT("Completed DMA Setup \n\r\n\r");
//
// Operation starts
//
green_led = 2; //green led on
while(FOREVER)
{
// Check to see if one second has elapsed. If so, make some updates.
//
if(time_flag)
{
time_flag = 0;

  • Hi,

    The systick interrupt should be ticking even if your main code is stuck on a while loop. Does this behavior happen if you don't force that thermometer_init() failure, and put a while(1) loop in your code?

    Also, what happens in thermometer_init()? Have you ensured that there isn't any memory corruption that could be happening due to unsafe pointer usage and such that may cause the system to behave unexpectedly?

    Regards,

    Michael

  • Michael,

    Thank you very much for you reply. Setting the infinite loop somewhere else was an excellent idea!

    Perhaps I am a little obsessed with catching errors, but I saw that the drivers for I2C have the capacity to return failure or success, and I am always weary of external devices, even more of simple serial links like I2C, so I decided to use the feature in my code.

    What I had forgotten, and I realized when installing the infinite loop in the area of the code where the temperatures are read, is that I have to reset a couple of global variables in the Systck interrupt handler for it to work properly. I basically count interrupts at 125 ms that I use to blink LEDs and every eight I set a flag to trigger a loop in the main program that resets the counter and reads the temperature among other things (I know I should have used a semaphore, but I had left that for later). I could have taken care of resetting the counter in the interrupt handler, but this allowed me to check it in the main loop if the code was running timely (again my obsession with error catching).

    Anyway, I just added the loop to check for the one second flag and reset the counter in the infinite loop, and it works!

    No problems with Systick, just stupid me.

    Best regards,

    Ramon