Click here to Skip to main content
15,868,016 members
Articles / Programming Languages / C

LCD with USB Toolstick c8051

Rate me:
Please Sign up or sign in to vote.
4.06/5 (17 votes)
22 Mar 2009CPOL2 min read 54.4K   1.8K   54   9
LCD with USB Toolstick c8051

Introduction

This is a LCD (MC20E2D-SYL) 8-bit 2x20 LCD module with Silabs 'toolstick dauther (F330)' updated with new firmware (in 'timer.zip' - LCD controller) and 'debug adapter(F321)' (also known as 'toolstick EK') made unit.

IMG005s.JPG

Prototype

usbio.JPG

With that, you can send text to display connected through USB debug adapter.

Prototype board:
To use 'usbhidio' you must update firmware for 'debug adapter'.
Toolstick --really is named 'Debug adapter' firmware in download section at the top
(to update use 'toolstick base adapter').
On desktop, run usbhidio2.exe (VB6) and type text on screen. Make sure that baud is 9600 and you are ready.

Software can be modified and run independently by supplying power.
Connections are seen on this page: http://www.8051projects.net/lcd-interfacing/introduction.php.

lcdpins.jpg

I made it like this:

<------------------ 'Toolstick F330'-----------------> <---Display--->
P1.0 to P1.7 P0.6 P0.7 P0.4(TX) P0.5(RX) VDD(3V) GRD&RW 5V
^ ^ ^ ^ ? ^ ^ ^ ^
DB0 to DB7 EN RS RX(25) TX(26) PIN6 GRD USB

<--------Display-------> <------------- 'Debug adapter F321'------------>

To adjust background, replace resistor 1,5K between GRD and VEE(PIN3) on LCD.
Also on LCD input RW(PIN5) is tied to GRD.
See the image below for connections:

Click to enlarge image

This is a very small and accurate job - thus that can't solder- don't bother to.

Background

Take a look at the previous article Counter based c8051 and this CodeProject article LCD with parallel port.
Take a look at the next article USB IR with c8051.

Using the Code

On desktop application, just press enter on textbox to display data on LCD - For those that are interested in the code - here is the main routine:

C++
void main (void)
{
    uchar i;
    uchar j;
    uchar dummy;
    PCA0MD &= ~0x40; 		// Clear watchdog timer enable
    Timer0_Init (); 		// Initialize the Timer0
    Port_Init (); 			// Init Ports
    //SYSCLK_Init (); 		// Initialize Oscillator
    UART0_Init();
    EA = TRUE; 			// Enable global interrupts
    LED=0;
    LCD_RS = 0;
    LCD_RW = 0;
    TimerStart( SYS_TIMER, 500 ); 	// wait for display to wake up
    while( !TimerReady( SYS_TIMER ));
    LCD_init();
    LCD_Home();
    LCD_sendstring("Start");
    /*
    move_to_specific(2, 1);
    LCD_sendstring("LCD second string");
    TimerStart( SYS_TIMER, 1000 ); 	// wait for display to wake up
    while( !TimerReady( SYS_TIMER ));
    LCD_Home();
    LCD_sendstring("UART");
    */
    while(1)
    {
        if(TX_Ready == 1 && UART_Buffer_Size != 0 && Byte == 13)
        {
            LCD_Clear();
            j=0;
           //--------------
           for(i = 0; i < (UART_Buffer_Size - 1); i++ ){ // Initialize software timers.
               if(j>19)
               {    //line full 
                    move_to_specific(2, 1);
                    j -= 20; } LCD_senddata(UART_Buffer[i]); j++;
               }
               //--------------
               TX_Ready = 0; 	// Set the flag to zero
               TI0 = 1; 		// Set transmit flag to 1
         }
    } 				// Loop forever
} 

Points of Interest

There are a lot of samples on the internet, but it is hard to find an article about displaying text through USB and using 8-bit LCD like MC20E2D-SYL.

History

  • 27th February, 2009: Initial post
  • 19th March, 2009: Article updated

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Estonia Estonia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Mic8-Aug-13 13:57
Mic8-Aug-13 13:57 
Generalcomments Pin
Shane Story2-Mar-09 7:42
Shane Story2-Mar-09 7:42 
GeneralRe: comments Pin
Markbanang23-Mar-09 2:45
Markbanang23-Mar-09 2:45 
GeneralRe: comments Pin
Shane Story23-Mar-09 2:49
Shane Story23-Mar-09 2:49 
GeneralRe: comments Pin
Shane Story23-Mar-09 2:51
Shane Story23-Mar-09 2:51 
GeneralRe: comments Pin
Rick York24-Mar-09 11:38
mveRick York24-Mar-09 11:38 
Generalinteresting Pin
Luc Pattyn27-Feb-09 9:53
sitebuilderLuc Pattyn27-Feb-09 9:53 
GeneralRe: interesting Pin
ingvar81-Mar-09 22:27
ingvar81-Mar-09 22:27 
GeneralRe: interesting Pin
ingvar81-Mar-09 23:05
ingvar81-Mar-09 23:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.