rslisiecki wrote on Monday, January 14, 2013:
I am seeing a semaphore active just after the start of the scheduler but before the tick interrupts start. My tick ISR “gives” the semaphore and I have a simple task that blocks on the semaphore. How can the semaphore be active before the first tick of the tick ISR? I am monitoring the status of the scheduler, task and tick ISR using an oscilloscope and some port lines. I am using an MSP430F169 processor with code modified from your “MSP430X_MSP430F5438_CCS” demo project. Everything seems to be working with installed FreeRTOS at this time except for this anomaly. I have no stack or heap overflow issues.
Here’s what the tic ISR looks like. global_ulTest1 is set to 0 in main() before the scheduler is started. There are no other interrupts active in this system.
#pragma vector=configTICK_VECTOR
interrupt void vTickISREntry( void )
{
//extern void vPortTickISR( void );
extern void vPortPreemptiveTickISR( void );
//extern void vPortCooperativeTickISR( void );
static int nCount;
static portBASE_TYPE xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE;
// Use a hardware counter to tell when to signal vTask1 using the semaphore
global_ulTest1++;
if (global_ulTest1 >= 512) // once a second
{
global_ulTest1 = 0;
// Give the semaphore to the handler, in this case, vTask1
xSemaphoreGiveFromISR(xBinarySemaphoreTest1, &xHigherPriorityTaskWoken);
if (xHigherPriorityTaskWoken == pdTRUE)
{
// Perform a required context swtich in the MSP430 context
vTaskSwitchContext();
}
}
// Make sure that all of the clock oscillators and the CPU are turned-on
// They could be off if the designer put the processor into a sleep
// state for the idle task.
//__bic_SR_register_on_exit( SCG1 + SCG0 + OSCOFF + CPUOFF );
// The following calls to FreeRTOS allow it to update its tick counter
// and manage tasks that are blocked.
// Note: This project uses configUSE_PREEMPTION = 1
#if configUSE_PREEMPTION == 1
vPortPreemptiveTickISR(); // Note: This is a call to an assembly routine in portext.asm
#else
vPortCooperativeTickISR(); // Note: This is a call to an assembly routine in portext.asm
#endif
// Toggle the red LED (X30) on the iBox board in order to watch the tail of this ISR.
for (nCount = 0; nCount < 30; nCount++)
{
P5OUT = P5OUT & 0XFD;
P5OUT = P5OUT | 0X02;
}
// Clear Timer_A’s interrupt flag to allow another tick
TACTL = // Timer_A Control Register
(TASSEL1 * 0) | // Timer_A clock source select: 00=TACLK
(TASSEL0 * 1) | // 01=ACLK 10=SMCLK 11=INCLK
(ID1 * 0) | // Input divider: 00=/1 01=/2 10=/4 11=/8
(ID0 * 0) | //
(MC1 * 0) | // Mode control: 00=stop mode (timer halted) 01=up mode
(MC0 * 1) | // 10=continuous mode 11=up/down mode
(TACLR * 0) | // Timer_A clear: 1=reset TAR and divider
(TAIE * 1) | // Timer_A interrupt enable: 0=disabled
(TAIFG * 0); // Timer_A interrupt flag: 0=no interrupt pending
} // end of interrupt void vTickISREntry( void )
// End of port.c