Professional Documents
Culture Documents
box in Micro C/OS-II using LPC2148 ALGORITHM Initialize the header file If OS_CR
ITICAL_METHOD==3 then it will allocate local storage for variable type OS_CPU_SR
cpu_sr=0 and end if statement Define SW1 and SW2 for Pin 0.10 and 0.11 OS_EVEN
structure created for OSMboxPost() and OSMboxPend() OS_STK is used to create ow
n stack space for task1,and task2 Declare the task functions Initialize variable
i and call LPC2148BSPInit() Set pins 0.12 and 0.13 of port0 as output and call
OSInit() OSTaskCreate() is used to create task1,and task2 with priority so it ca
n be managed by uc/os-II OSMboxCreate() create and initializes mailbox. OSMboxPo
st() sends message to a task through mailbox and call OSStart()
Task1 Initialize variable err, i, and pointer variable msg Initialize LPC2148BSP
Init() Within infinite loop, OSMboxPend() used by the task to receive a message
and assign it in variable msg Assign i=*msg If SW1==0 then increment i and print
the value of i
OS_ENTER_CRITICAL() used to disable processors interrupt and enters into critical
section of code where it waits until SW1==0