This microcontroller family can support software interrupts. These microcontrollers can be driven from a 32kHz crystal oscillator. The time functions have been written assuming such an oscillator drives the timer. If this is not the case, modify the functions in porttime.h and the timer initialization functions in tr_port.c.
Note that in the MSP430 architecture, the low-power state of the processor is stored in the status register. Since this is part of the context, per-task power control is automatic. To keep the processor in low-power state during idle time, simple define the idle task as
void idle_task(void *dummy) { while(1) { _BIS_SR(LPM3_bits); } }
Tested with TI MSP430x1611
If no TiROS API functions will be called, interrupts will stay disabled, then the ISR can be written very simply. See the requirements in Usage with Interrupt Service Routines.
interrupt (IVECTOR) ISR_function(void) { // do stuff }
If TiROS API calls have to be used, the form of the ISR depends on whether TIROS_KERNEL_TRAP_ENABLED is set (It is set as a default). If TIROS_KERNEL_TRAP_ENABLED is set to 1, the ISR is simple
interrupt (IVECTOR) ISR_function(void) { int x; OS_CRITICAL_ENABLE(); // Only needed if any critical sections // will be used and interrupt nesting is enabled. OS_ISR_BEGIN(); // Mark the beginning of an ISR. Note // that if OS_CRITICAL_ENABLE() is also // present, then this comes after // that. x = 3; Do more stuff .... OS_ISR_END(); }
If TIROS_KERNEL_TRAP_ENABLED is set to 0, the ISR would look as below. Use the ISR implementation in tr_port.c as a reference.
interrupt (IVECTOR) ISR_function(void) __attribute__ ( (naked)) interrupt (IVECTOR) ISR_function(void) { HALINT_ISR_ENTRY(); OS_ISR_BEGIN(); perform_actions(); OS_ISR_END(); HALINT_ISR_EXIT(); }