Download 6 - Diversant Software
Transcript
6
Overview
os_create_task (CONSUMER_NBR); /* Create the consumer task */
send_mes = 1;
for (;;) {
/* end-less loop */
/* Send actual value of "send_mes" to the mailbox 0 */
/* If the mailbox is full, wait until there is room */
/* for the message
*/
os_send_message (0, send_mes, 0xff);
send_mes++;
}
1
}
void consumer_task (void) _task_ CONSUMER_NBR _priority_ 1
{
unsigned int rec_mes;
for (;;) {
/* Read from the mailbox 0 to the variable "rec_mes" */
/* Wait for a message if the mailbox is empty
*/
os_wait (K_MBX+0, 0xff, &rec_mes);
/*
... Perform some calculations with "rec_mes"
*/
}
}
void main (void)
{
/* Initialize the system and start the producer task */
os_start_system (PRODUCER_NBR);
}
Compiling and Linking the Program
The most convenient way is to use µVision-51/251 for this purpose. A project
definition file named SAMPLE.PRJ contains all required settings and
automatically identifies all required files. Use ‘Open project’from the ‘Project’
menu to select this file. SAMPLE.PRJ can be found in the sub-directory RTX51
(for RTX-51) or RTX251 (for RTX-251) in the C51/C251 tools directory.
By use of the ‘Make: Build project’selection out of the ‘Project’menu the sample
program is compiled and linked in one step.