The MicroC/OS-II Mutex design example demonstrates the use of MicroC/OS-II mutual exclusion semaphores (mutex). It also serves as a good starting point for designs using MicroC/OS-II with Nios® II processors. MicroC/OS-II Mutexes are very similar to semaphores and are generally used to protect shared resources and/or facilitate task synchronization. The main difference between a mutex and a regular semaphore is that a mutex has the concept of raising the priority of a task that owns the mutex.
In this MicroC/OS-II Mutex design example, two different tasks are accessing a shared resource, which, in this case, is an LCD display.
The task called task1() prints out the status of the Joint Task Action Group (JTAG) UART connection on the top line of the LCD. A "1" signifies that the JTAG UART detects a valid connection to the nios2-terminal program. A "0" signifies that the JTAG UART no longer has an connection with the nios2-terminal program. Upon start-up with STDOUT set to the JTAG UART, a valid connection is detected. If the nios2-terminal program is stopped, or the JTAG cable is disconnected, the state of the connection will change a few seconds later. The task called task2() prints out how long the system has been running on the bottom line of the LCD.
Using This Design Example
Ensure that you have installed a Nios II development kit. Download the MicroC/OS-II Mutex design example and unzip the files into a directory under <Nios II kit path>/examples/software (for example, <Nios II kit path>/examples/software/ucosII_mutex). If installed in this directory, the design example will be available as a Nios II integrated development environment (IDE) project template. The MicroC/OS-II Mutex design example includes the project settings required to run this design example on the supported target hardware configuration. To use the MicroC/OS-II Mutex design example, simply create a new C/C++ application project in the IDE, and choose the desired project template.
The use of this design is governed by, and subject to, the terms and conditions of the Intel® Design Example License Agreement.
The MicroC/OS-II design example requires the following devices to be present in the target hardware design:
- LCD character display
- JTAG UART
You can run this design example on the following Nios II hardware design examples:
- Stratix® II design examples
- Full Featured
- Cyclone® II design examples
- Full Featured
Design Examples Disclaimer
These design examples may only be used within Intel Corporation devices and remain the property of Intel. They are being provided on an “as-is” basis and as an accommodation; therefore, all warranties, representations, or guarantees of any kind (whether express, implied, or statutory) including, without limitation, warranties of merchantability, non-infringement, or fitness for a particular purpose, are specifically disclaimed. Intel expressly does not recommend, suggest, or require that these examples be used in combination with any other product not provided by Intel.