0% found this document useful (0 votes)
38 views2 pages

Implemention of Mailbox Function Using Lpc2148 AIM Algorithm

This document describes implementing a mailbox function using Micro C/OS-II on an LPC2148 microcontroller. It initializes header files and allocates stack space for two tasks. It creates tasks using OSTaskCreate(), a mailbox using OSMboxCreate(), and sends/receives messages between tasks using OSMboxPost() and OSMboxPend(). The two tasks increment/decrement a variable when buttons are pressed and delay using OSTimeDlyHMSM().

Uploaded by

Mohan Kumar Smk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views2 pages

Implemention of Mailbox Function Using Lpc2148 AIM Algorithm

This document describes implementing a mailbox function using Micro C/OS-II on an LPC2148 microcontroller. It initializes header files and allocates stack space for two tasks. It creates tasks using OSTaskCreate(), a mailbox using OSMboxCreate(), and sends/receives messages between tasks using OSMboxPost() and OSMboxPend(). The two tasks increment/decrement a variable when buttons are pressed and delay using OSTimeDlyHMSM().

Uploaded by

Mohan Kumar Smk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

IMPLEMENTION OF MAILBOX FUNCTION USING LPC2148

AIM
To create a mailbox in Micro C/OS-II using LPC2148
ALGORITHM
Initialize the header file
If OS_CRITICAL_METHOD==3 then it will allocate local storage for variable
typeOS_CPU_SR cpu_sr=0 and end if statement
Define SW1 and SW2 for Pin 0.10 and 0.11
OS_EVENT structure created for OSMboxPost() and OSMboxPend()
OS_STK is used to create own 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 can be managed
byuc/os-II
OSMboxCreate() create and initializes mailbox.
OSMboxPost() sends message to a task through mailbox and call OSStart()
Task1
Initialize variable err, i, and pointer variable msg
Initialize LPC2148BSPInit()
Within infinite loop, OSMboxPend() used by the task to receive a message and assign itin
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
criticalsection of code where it waits until SW1==0
If SW1!=0 then it use OS_EXIT_CRITICAL to enable processors interrupt and
comesout of critical section of code
OSMboxPost() sends message to a task through mailbox and assign it in variable err
OSTimeDlyHMSM used to delay the task for user specified time of 100milliseconds
Task2

Initialize variable err, j, and pointer variable msg

Within infinite loop, OSMboxPend() used by the task to receive a message and assign itin
variable msg

Assign j=*msg

If SW2==0 then decrement j and print the value of j

OS_ENTER_CRITICAL() used to disable processors interrupt and enters into criticalsection of


code where it waits until SW2==0

If SW2!=0 then it use OS_EXIT_CRITICAL to enable processors interrupt and comesout of


critical section of code

OSMboxPost() sends message to a task through mailbox and assign it in variable err

OSTimeDlyHMSM used to delay the task for user specified time of 50milliseconds
CODING
#include
"includes.h"#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register*/OS
_CPU_SR cpu_sr = 0;#endif #define sw1 IO0PIN_bit.P0_10#define sw2
IO0PIN_bit.P0_11OS_EVENT *comm;OS_STK Task1stk[1000];OS_STK Task2stk[1000];

You might also like