______________________________________________________________________ > < > LCD TEXT driver v 1.02 < > for < > PICos18 release 2.00 < > < > PICos18 - Real-time kernel for PIC18 family < > < > < > www.picos18.com www.pragmatec.net < >______________________________________________________________________< This file contains all necessary informations to use properly the HITACHI HD4478 LCD drivers for PICos18 v2.00. Download the last PICos18 kernel version from www.picos18.com. ______________________________________________________________________ > < > I - Zip file content < >______________________________________________________________________< The hd4478 zip file contains : - hd4478_8b.c : to use with a HD4478 LCD in 8 bits mode - hd4478_4b.c : to use with a HD4478 LCD in 4 bits mode - hd4478.h : header file - hd4478.txt : this file To use the HD4478 PICos18 driver, first unzip the file and select the C file dedicated to your hardware (either 8b if you access your LCD with a full size port, or 4b if you only use a low or high nibble of the port). Place the C and H file in your project directory. Adapt the LCD settings properly depending of your LCD interface (#define present at the top of the C file). This driver is supposed to be use with PICos18 and has been tested with MPLAB 6.62 and C18 v2.40. Do not use this driver at a frequency lower than 8 Mhz (use the PIC18 PLL to increase the internal frequency). ______________________________________________________________________ > < > II - Hardware settings < >______________________________________________________________________< In the hd4478_Xbits_drv.c, update the local defintions to match your hardware: /********************************************************************** * ----------------------- LCD USER SETTINGS -------------------------- **********************************************************************/ #define COLUMN 8 /* Character number per line */ #define LINE 2 /* Number of line */ #define LCD_ALARM_ID 1 /* Alarm ID in tascdesc.c*/ #define DATALATCH LATD /* DATA port */ #define TRISDATA TRISD #define PORTDATA PORTD #define RS_PIN LATCbits.LATC0 /* CMD or DATA */ #define TRIS_RS TRISCbits.TRISC0 #define E_PIN LATCbits.LATC2 /* Enable transfer */ #define TRIS_E TRISCbits.TRISC2 #define RW_PIN LATCbits.LATC1 /* READ or WRITE */ #define TRIS_RW TRISCbits.TRISC1 ______________________________________________________________________ > < > III - TASCDESC settings (1) < >______________________________________________________________________< Updates also the tascdesc.c file to take into account the new LCD task in your application : /********************************************************************** * ----------------------- TASK & STACK DEFINITION -------------------- **********************************************************************/ #define DEFAULT_STACK_SIZE 256 DeclareTask(TASK0); DeclareTask(HD4478_DRV); ... volatile unsigned char stack0[DEFAULT_STACK_SIZE]; volatile unsigned char stack_hd4478[256]; ... ______________________________________________________________________ > < > IV - TASCDESC settings (2) < >______________________________________________________________________< Finally add the task and alarm descriptor to the tascdesc.c file : ... /********************************************************************** * --------------------------- HD4478 driver -------------------------- **********************************************************************/ rom_desc_tsk rom_desc_hd4478 = { HD4478_DRV_PRIO, /* prioinit from 0 to 15 */ stack_hd4478, /* stack address (16 bits) */ HD4478_DRV, /* start address (16 bits) */ READY, /* state at init phase */ HD4478_DRV_ID, /* id_tsk from 0 to 15 */ sizeof(stack_hd4478) /* ctx address (16 bits) */ }; ... AlarmObject Alarm_list[] = { /******************************************************************* * -------------------------- First task --------------------------- *******************************************************************/ { OFF, /* State */ 0, /* AlarmValue */ 0, /* Cycle */ &Counter_kernel, /* ptrCounter */ TASK0_ID, /* TaskID2Activate */ ALARM_EVENT, /* EventToPost */ 0 /* CallBack */ }, ..., /******************************************************************* * ---------------------- Alarm LCD task --------------------------- *******************************************************************/ { OFF, /* State */ 0, /* AlarmValue */ 0, /* Cycle */ &Counter_kernel, /* ptrCounter */ HD4478_DRV_ID, /* TaskID2Activate */ ALARM_EVENT, /* EventToPost */ 0 /* CallBack */ } }; Note : In the hd4478_Xbits_drv.c, change the definition of LCD_ALARM_ID in order to match with the above structure position. ______________________________________________________________________ > < > V - TASK Settings < >______________________________________________________________________< Open define.h and add this 3 definitions with correct value : #define LCD_EVENT 0x01 #define HD4478_DRV_ID 5 #define HD4478_DRV_PRIO 10 The LCD task is considered like a driver, that means you have to give one of the highest priority to the LCD driver to let it run each time the LCD content is updated. ______________________________________________________________________ > < > VI - LCD driver usage < >______________________________________________________________________< In the application task, include the driver header: #include "hd4478.h" See hereafter an basic example dedicated to a 2x8 LCD: #include "define.h" #include "hd4478.h" /********************************************************************** * Definition dedicated to the local functions. **********************************************************************/ #define ALARM_TSK0 0 /********************************************************************** * ------------------------------ TASK0 ------------------------------- * * First task of the tutorial. * **********************************************************************/ TASK(TASK0) { // Wait for the end of the LCD init sequence SetRelAlarm(ALARM_TSK0, 1000, 0); WaitEvent(ALARM_EVENT); ClearEvent(ALARM_EVENT); LcdClear(); // LcdPrintString(const string, col, line) LcdPrintString("PICos18", 0, 0); LcdPrintString("LCD v1.0", 0, 1); TerminateTask(); } ______________________________________________________________________ > < > VII - Conclusion < >______________________________________________________________________< This LCD driver is provided from the PICos18 web site with other drivers dedicated to other peripherals. Some zip files are also provided to be used with a driver. For instance a "LCD library" should be delivered with a set of functions to manipulate the LCD data (printing char, int, float, string,...). Do not hesitate to check periodicaly the www.picos18.com web site in order to download the last versions of PIC18 drivers for PICos18. /* End of File : hd4478.txt */