SLAU132V October 2004 – February 2020
__interrupt void Timer_B1 (void)
{
switch( TBIV )
{
case 0: break; /* Do nothing */
case 2: TBCCR1 += 255;
state +=1;
break;
case 4: TBCCR0 = 254;
TBCCR1 = 159;
state =200;
break;
case 6: break;
case 8: break;
case 10: break;
case 12: break;
case 14: break;
default: __never_executed();
}
}
In Example 8 using the __never_executed( ) intrinsic asserts that the value of TBIV can only take on the values specified by the case labels, namely the even values from 0 to 14. Normally, the compiler would have to generate code to handle any value which would result in extra range checks. Instead, for this example, the compiler will generate a switch table where the value of TBIV is simply added to the PC to jump to the appropriate code block handling each value represented by the case labels.