Semaphore Assignment
- Program Timer0A for 500ms periodic interrupt
- Timer programming How to …
- Create two tasks as Task 1 and Task 2.
- Task 1 should be continuous processing task and display as “Task 1 is Running…”
- Task 2 will wait for the semaphore
- Toggle Blue LED if semaphore taken in the Task 2
Note: Semaphore objects must be initialised before use by calling atomSemCreate(). Once initialised atomSemGet() and atomSemPut() are used to decrement and increment the semaphore count respectively.
Code Snippets
/* Task 1 is continuous processing Task */ void Task1(uint32_t entry_param) { while(1) { printf("%s", "Task1 is Running ...\n\r"); for(volatile auto uint32_t ul = 0; ul < 0xffff; ul++ ){ ; } } } /* Task 2 waits for semaphore */ void Task2(uint32_t entry_param) { while(1) { /* Wait for (Get) semaphore, If Yes, Toggle Blue LED */ } } /* Timer0A Interrupt Service Routine */ void timer0a_isr((void) { TIMER0_ICR_R = 0x01; /* clear Timer0A timeout interrupt */ atomIntEnter(); /* Give (Put) Semaphore */ atomIntExit(0); }
References
Recent Comments