ChipCenter Questlink
SEARCH CHIPCENTER
Search Type:
Search for:




Knowledge Centers
Product Reviews
Data Sheets
Guides & Experts
News
International
Ask Us
Circuit Cellar Online
App Notes
NetSeminars
Careers
Resources
FAQ
EE Times Network
Electronics Group Sites

EMBEDDED MULTITASKING


Circuit Cellar Online
THE MAGAZINE FOR COMPUTER APPLICATIONS
Circuit Cellar Online offers articles illustrating creative solutions
and unique applications through complete projects, practical
tutorials, and useful design techniques.

EMBEDDED MULTITASKING

The Easy Way
by Charles Kosina

Start ý An Example ý State Machine Control ý Keyboard Scanning ý Receive Serial Data ý LCD Module ý Transmit Data ý Debugging Techniques ý Other Options ý Sources and PDF

AN EXAMPLE

I have always found that the best way to explain something is by example. Just before writing this article, I received a development kit from Cygnal for its C8051F000 microcontroller. The microcontroller has all the usual 8051 features but also includes an 8-channel 12-bit ADC and two channels of DAC. Flash memory programming and debugging is via its JTAG interface. And, it boasts a whole lot of other goodies, as Tom Cantrell explains in his article "Cygnal Processor" (Circuit Cellar Online, September 2000).

What better way is there to get familiar with the ýF000 than to write some code and see how it performs? Iýve provided sample listings throughout this article, but the full source code may be downloaded.

Figure 1 shows a block diagram of the application. I kept it simple to illustrate the technique, and so you wont be overwhelmed by the complexity of the application.

Figure 1ýI used the Cygnal C8054F000 development kit for this example. However, most 8051 derivatives may be used as only a few I/O bits are needed.

 

A standard 4 ý 4 keyboard matrix is scanned using Port 2. The scanning is not continuous but runs at a rate of 60 scans per second. A standard LCD module is operated in 4-bit mode despite the fact that there are plenty of spare I/O bits. In most designs, I/O pins are at a premium, and the 4-bit mode is often fast enough. And finally, the RS-232 port is used for transferring data.

So, letýs set up four tasks, running concurrently (see Table 1).

Task

Function

Task 1

Scans the 4 ý 4 keyboard and stores the keystroke in a RAM location

Task 2

Receives data on the RS-232 port and stores it in a memory buffer

Task 3

Monitors tasks 1, 2, and 3 and writes data to the LCD module

Task 4

Transmits data to the RS-232 port

Table 1ýOnly four tasks are used in this simple example. Other tasks may be added easily with little affect on the firmware structure.

Any 8051 derivative may be used for this example with only minor changes to the code. Note that the I/O bit allocation for the ýF000 serial port differs from the 8051 standard.


Circuit Cellar provides up-to-date information for engineers. Visit www.circuitcellar.com for more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com or subscribe online. ýCircuit Cellar, the Magazine for Computer Applications. Posted with permission.
Click here to get your listing up.

Copyright © 2003 ChipCenter-QuestLink
About ChipCenter-Questlink  Contact Us  Privacy Statement   Advertising Information  FAQ