LCD Driver code in C for M68EVB08GB60 Board

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LCD Driver code in C for M68EVB08GB60 Board

5,687 Views
sonu
Contributor I
I am using M68EVB08GB60 Board and trying to invoke the LCD. I Tried with AN2940 Application note Software, But it is not working. Can someone help me in LCD Driver
Labels (1)
0 Kudos
17 Replies

994 Views
sonu
Contributor I
Hi I am still stuck with LCD no response from form. Pls help.
 
0 Kudos

994 Views
bigmac
Specialist III
Hello,
 
Perhaps you should post the exact code you are using for the LCD interface.  This should include the header file LCD.h, and also your initialisation code for port G.
 
Regards,
Mac
 
 
 
0 Kudos

994 Views
sonu
Contributor I
I am sending you the code.
0 Kudos

994 Views
eckhard
Contributor V
Hello,

if I read the programm correct, you use PTG Bit0 to Bit3 for the LCD.

#define lcdExists 1 /* If LCD does not exist, do not declare */
/* this #define */
#ifdef lcdExists
#define lcd4bit 1 /* 4 bit interface; comment this line if */
/* is 8 bit interface */
#define lcdE PTED_PTED7 /* Enabled pin of LCD */
#define lcdEDD PTEDD_PTEDD7 /* Data Direction of Enabled Pin */
#define lcdRS PTED_PTED6 /* RS pin of LCD (Data/Instruction Select)*/
#define lcdRSDD PTEDD_PTEDD6 /* Data Direction of RS Pin */
#define lcdPort PTGD /* Port of 4 data bits to lcd connection */
#define lcdPortDD PTGDD /* Data direction for 4 data pins */
// #define lcdPortRW PTGD_PTGD3 /* Data direction for 4 data pins
#ifdef lcd4bit
#define lcdDataPins 0 /* Number of pin of the port where begin */
/* the data pins (4 pins). These */
/* pins must be consecutive. Only */
/* in case of 4 bit interface */
#endif
#endif

Starting at Pin 0.

in your LCD Code are these Statements

/* Configure Pins to output and data sended */

#ifdef lcd4bit
lcdPortDD |= (0xF0 lcdDataPins); /* LCD port pins as output */
lcdPortDD= 0xf0;
lcdPort &= PORTMASK; /* Taking the 4 pins of the port */
lcdPort |= OUTNUMBER(0x00); /* Nibble sended */
#else
lcdPortDD = 0xFF;
lcdPort = 0x00;
#endif

ad you are setting the Data Direction as Input with lcdPortDD 0 0xF0 the lower half of the Port is input and the upper half stays unchanged.

Eckhard
0 Kudos

994 Views
bigmac
Specialist III
Hello,
 
As Eckhard has already observed, your 4-bit data connections are for PTG0 through to PTG3.  However, the demo board for the GB60 requires that PTG4 through to PTG7 are actually used.  This will require the following change -
 
#define  lcdDataPins  4
 
In addition, I notice that you do not currently define or initialise the RW pin of the display.  This is connected to PTG3.  At the start of your LCD initialisation code, the following might be added -
 
PTGDD_PTGDD3 = 1;  // Set pin for output
PTGD_PTGD3 = 0;    // Set RW = 0 (write only)
 
Further, the User enable switch #4 must be on to enable data to reach the display.
 
I also notice that the PORTMASK definition, plus the problem code described by Eckhard, differs from the code for the original Application Note, and has become confused.  The original code should be OK.
 
Regards,
Mac
 

Message Edited by bigmac on 2007-02-2712:48 AM

0 Kudos

994 Views
sonu
Contributor I
Thanks bigmac and Eckhard for giving me support. Now i am able to initilize the LCD and all the bit changes are ok.
But still i am not able to display the message on LCD. It moves inside the cycle variable and never end. Is their some time calulation of frequacy selection error. Pls check.
 
Pls see the code i did to modify the timer inilization.Code:
/* Disable the Cop and the LVI module power */
 // CONFIG1_COPD =    1;
 // CONFIG1_LVIPWRD =  1;
  //SOPT_COPE=0;
    // SRS_COP=0;
    // SRS_LVD=0;
     SOPT_COPE=0;
     SPMSC1_LVDE=0;
  /* Using the External Crystal Oscilator. Wich frecuency is Fxtal=9.9804MHz */
 // CONFIG2_OSCCLK0=0;
  //CONFIG2_OSCCLK1=1;
    //ICGC1_OSCSTEN=0;
   // ICGC1_REFS=1;
   // ICGC1_CLKS=10;
    ICGC1_RANGE=1;
    ICGC1_CLKS1=1;
    ICGC1_CLKS0=1;
void TimerInit(void){  TPM1SC_TOIE = 1;     /* Enable overflow interrupt*/   TPM1SC_CLKSB = 0;  TPM1SC_CLKSA = 1;                             TPM1SC_PS0 =  0;     /* Select prescale divisor. Preescaler = 1              */  TPM1SC_PS1 =  0;                     TPM1SC_PS2 =  1;                       TPM1MOD = 0x01f3;    /* For an overflow interrupt of aprox 100 us, this need */                     /*        499counts because each count take 1 Tbus, so */                     /*        (499 * 1Tbus) = 100.09us                      */    //TPM1SC_CPWMS = 1;    /* For normal operation                                 */ // TPM1SC_TOF = 1;}

 

Message Edited by sonu on 2007-02-2802:11 PM

0 Kudos

994 Views
bigmac
Specialist III
Hello,
 
Your remaining problem is not clear to me from the description.  Perhaps you could elaborate on what happens when you attempt to display a message, and how you think the problem is related to the timer set up.
 
Regards,
Mac
0 Kudos

994 Views
sonu
Contributor I
Hi Mac,
   The code send is the modification from standard LCD Driver code available. This code decide the crystal selection, range and delay time.
  
   After making the said modifications, if i check them in debugger/simulator i found that all the bits are responding in the asked pattern. The LCD cursor also goes off and clear the display.
 
But when it reach to check the timerLCD function, then it keep on running between cycle variable, Local_LCDStatusInit, and directly jump on main.c
     {
       current_function_flag = 7;
       LCDCursor(0x4A);
     } -- end of this function.
 
and then jump to
 
 cycles++;
   if (cycles == 100) {
     cycles_100++;
     cycles = 0;
     if (cycles_100 == 100) {
       cycles_10000++;
       cycles_100 = 0;
 
And this jumping never end.
 
Because of this it never display the Text on disply.
 
 
 
0 Kudos

994 Views
bigmac
Specialist III
Hello,
 
I attempted to run your code in simulation mode, but operation halted immediately after interrupts were enabled, with the errors "Attempt to use invalid or uninitialized memory" and "Interrupt processing failed" messages displayed.  This is probably what you were observing.  I eventualy realised that, for the GB60 device, the timer overflow vector is interrupt 8.  This differs from the HC908AP64, that uses interrupt 7.  Once this correction was made, the errors no longer occurred.
 
I notice that you have made considerable alteration to the program flow of the function LCDInit(), such as commenting out all the break instructions within the switch structure.  This would mean that the driver would not operate as originally intended.
 
Incidently, the original main() code from the Application Note could never have worked as intended - there are two instances where two writes are attempted to "write once" registers (for the AP64 device). 
 
Regards,
Mac
 
0 Kudos

994 Views
sonu
Contributor I
Hi,
 I am sending you now with all the modifications suggested. The intruptt 8 also used, but problem is same that it get halted on same postion where i specified in last mail.
Can you check the latest code i sent as  attachment on your evaluation board, so you can catch the problem.
I am not getting any message, you specified in your last mail.but the program halted at the specified point given in last message.
 
0 Kudos

994 Views
bigmac
Specialist III
Hello,
 
I note that you have commented out the line within main.c that enables interrupts.  This would mean that the overflow interrupt would never occur.  I can see nothing else in your code that is an obvious problem.
 
Actually, I do not have an evaluation board - I can only test the code using full chip simulation.
 
Regards,
Mac
 
0 Kudos

994 Views
sonu
Contributor I
Hi,
  Thanks MAC, That code does not work on evaluation Board.
But i did few major modifiation, now i am able to run the code.
Thanks to ALL how supported me for LCD coding.
I hope you will help me in my future activities too.
 
0 Kudos

994 Views
Alban
Senior Contributor II
Dear Sonu,
 
Would you please post the working project ?
This would benefit to other readers who would like to do the same as you and could encounter problems.
 
In advance, thank you.
Alban.
0 Kudos

994 Views
J2MEJediMaster
Specialist I
If you do a search on "LCD driver" using the search feature at the bottom left of this web page, you can find a number of previous discussions which cover writing an interface for a LCD. Here is one thread and another which might help get you started. Be sure you read the entire thread. HTH.

---Tom
0 Kudos

994 Views
sonu
Contributor I
Hi Tom,
  I am already using the Downloaded software AN2940 Application Note.
With my Board i am using the 4-bit communication, The problem i am facing when i see from the debugger, All other bits status getting changed except the PTG port 4 pins used for the display 4-bit data send. If can try that code in Full Chip Simulation mode and reply me the problem.
 
 
0 Kudos

994 Views
bigmac
Specialist III
Hello,
 
Some things to check -
  1. Did you change the first part of the header file LCD.h to reflect the I/O pins used by your demo board?
  2. Within your Port G initialisation code, do you set PTG3 for permanently low output state?  This is the R/W signal for the display, that the driver code does not appear to define - the driver would assume this signal to  be always low (write only).
  3. On the User Enable DIP switch, did you set #4 to ON position, to enable the display?
Regards,
Mac
 
0 Kudos

994 Views
sonu
Contributor I
Yes I checked these points already.
And the status of PTGD port is not changing when i check in debugger.
The status of  PTGDD is 1.
 DIP Switch potion is ok.
- ALL User Enable Switches are ON.
- ALL DIP_SW are ON
- COM_SW switch 4 is ON.
 
 
 
0 Kudos