Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


newbie -- writing lcd driver

Posted by Nobody/Anonymous on April 4, 2006
I was given a HD44780 LCD module a few months ago and took interest in writing a driver for it when I was kicking the tires on FreeRTOS. Below is my approach, it's the first driver I've written and I was seeking comments. (I should say that I'm using FreeRTOS in pre-emptive mode with several tasks running. At this point everything is an exercise in programming, just to learn the basics.)

I first wrote a few core routines to manage the control and data lines out of an ATMega32. I employed a lot of macros to do the device/OS specific code (like PORT output, delays, critical sections, etc.) in case I wanted to use this on another platform. All the device/OS macros are kept in a lcd_port.h file. Since the LCD control signals are time sensitive, I protected each LCD command in a critical block. This way the driver is ensured that it can complete the current LCD command.

The next step was writting routines like lcd_char, lcd_string, etc. Since these are likely to change from application to application, I placed them in another .C file. In addition, since the eventual code will possibly be running in a pre-emptive OS, I placed mutex code in each LCD routine. In short, each LCD routine grabs the mutex while it's running, and gives it up when it's done, ensuring sequential text output. At this point, I have a collection of routines that I can easily use to display text on the LCD as well as a somewhat easy-to-port lower level driver.

The final step is integrating this into FreeRTOS. As an RTOS newbie, I'm a little unsure of how to continue. I'm assuming the mutex and critical sections place this application in the soft-realtime space. My tenative next step is to create an LCD-output task in FreeRTOS that handles output. This way the other tasks can fire off a message and continue working if needed. (I'm thinking that this approach would also minimize priority inversions.)

This is getting a little long winded, so I'll wrap it up here. As a newbie, is my approach sound? Any suggestions or glaring issues?


-- Joe

RE: newbie -- writing lcd driver

Posted by Nobody/Anonymous on April 4, 2006
Take a look at the PC port which you can run using Open Watcom. This uses a scheme whereby a task blocks on a queue. When a task want to print a message it sends a pointer to the message on said queue - waking the task which then reads and displays the message.

This way the mutual exclusion is handled by the fact that there is only one task that is permitted to access the hardware - in this case the vdu rather than an lcd - but the principal is the same.

[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists