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.

Timer interrupt: 112-D statement is unreachable (using driverlib on MSP430F5529)



I wanted to use the different capture and compare registers of "Timer A1" but I could not go inside the timer interrupt although I try to settup all the required functions. Am I missing something? I can go inside the interrupt when I use the TAIE overflow but not using the compare register values. I want to have many timer intterupts having different intervals. Is there another solution.

Inside the main function, I call init_TimerA1 once and I was hoping to use PortOn() and PortOff() functions below to start and stop a multiple timer interrupts of TimerA1 compare registers using "TIMER_A_enableCaptureCompareInterrupt()" and "TIMER_A_enableCaptureCompareInterrupt)" functions. 
But it keeps displaying 112-D statement is unreachable

void init_TimerA1(void)
{
   
    TIMER_A_clearTimerInterruptFlag(TIMER_A1_BASE);

    TIMER_A_configureUpMode(
             TIMER_A1_BASE,
             TIMER_A_CLOCKSOURCE_SMCLK,
             TIMER_A_CLOCKSOURCE_DIVIDER_64,
             (0xFFFF),                    
             TIMER_A_TAIE_INTERRUPT_DISABLE,                   //Not enabled because roll over interrupt is not needed
             TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE,     //not needed
             TIMER_A_DO_CLEAR
                                    );

    // 2. Setup Capture & Compare features
    TIMER_A_initCompare( TIMER_A1_BASE,
       TIMER_A_CAPTURECOMPARE_REGISTER_3,               // User CCR3 for compare
       TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE,        // can also be enabled later
       TIMER_A_OUTPUTMODE_RESET_SET,                      
       0x4000                                           // Compare value: 4000 = 1/4 second(does not matter)
     );

    TIMER_A_startCounter(TIMER_A1_BASE,  TIMER_A_UP_MODE );   //start the timer

}

//function to enable the compare register interrupt

void PortOn()
{

    TIMER_A_enableCaptureCompareInterrupt(TIMER_A1_BASE,TIMER_A_CAPTURECOMPARE_REGISTER_3);

}

//to disable the compare register interrupt
void PortOff()
{
    TIMER_A_disableCaptureCompareInterrupt(TIMER_A1_BASE,TIMER_A_CAPTURECOMPARE_REGISTER_3);

}

//******************************************************************************
//
//This is the TIMER1 interrupt vector service routine.
//
//******************************************************************************
#pragma vector=TIMER1_A1_VECTOR
__interrupt void TIMER1_A1_ISR(void)
{
        //Any access, read or write, of the TAIV register automatically resets the
        //highest "pending" interrupt flag
        switch ( __even_in_range(TA1IV, 14) ) {
        case  0: break;                                 //No interrupt
        case  2: break;                                 //CCR1 not used
        case  4: break;                                 //CCR2 not used
        case  6: break;                                 //CCR3    //WARNING shows:  112-D statement is unreachable

        GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);


        case  8: break;                                 //CCR4 not used
        case 10: break;                                 //CCR5 not used
        case 12: break;                                 //CCR6 not used
        case 14:

                break;
        default: break;
        }
}

  • Mekuria said:

    case  6: break;                                 //CCR3    //WARNING shows:  112-D statement is unreachable

            GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);



    looks like a sysntax error.
    Try this

     case  6: 
               GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
               break;                                 //CCR3    
    

  • Sri-Sri got it right. You get this error because the statement stands between a break (which exits the switch statement) and the next case. So there is no way to get there. Independent of what this statement does. And independent of whether the switch is inside an ISR or inside main.
    But it's not a syntax error, the syntax is right. :)

     It’s like writing an instruction after the return statement of a function. Or someting after a continue in a loop.

    Sometimes, when the compiler is re-arranging code by optimization, it may be that two identical code blocks are joined. Then you also might get this warning because th esecond instance is no longer reacahble. I had this case with MSPGCC.

**Attention** This is a public forum