Initialzation:
Table 1: Task Creation Settings | ||
---|---|---|
Task | Timeout Condition | Message Mask |
Keyboard | 30 - Task runs every 30 ms | 0xff - Not using messaging |
Measurement | 0 - Not using timeout | 0x01 - Initially waiting on task 0 (keyboard) |
Display | 0 - Not using timeout | 0x02 - Waiting on the measurement task |
DDRB = 0b11110011; //make most pins output except comparator PORTB = 0x00; //discharge capacitor DDRD = 0x00; TIMSK=TIMSK | 0x08; //only use input capture interrupt TCCR1B = 0; TCNT1 = 0; //and zero the timer ACSR = 0x07; //Interrupt enable, rising edge, input capture //Set up OS constants OSInit(OSTimeOut, OSDebug); //Define the tasks to the OS OSCreateTask(KbdTask, t0, NoMessage, NoPush); OSCreateTask(MeasureTask, 0, 0x01, MeasurePrep); //waiting for KbdTask OSCreateTask(DisplayTask, 0, 0x02, 0); //waiting for MeasureTask //Start the system OSStart(); //never returns