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) { // Set low power state here } }
Tested with TI MSP430x1611 To use the IAR tools for development: Set the following directories in the include path for project options ( C compiler->Preprocessor)
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.
#pragma vector=VECTOR_NUM __interrupt void ISR_function(void) { // do stuff }
If TiROS APIs will 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
#pragma vector=VECTOR_NUM __interrupt void 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(); }
This port currently requires TIROS_KERNEL_TRAP_ENABLED.