GLCD WITH ST7920 CONTROLLER

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
pumper
Posts: 277
Joined: 10 Jan 2011 17:37

GLCD WITH ST7920 CONTROLLER

#1 Post by pumper » 30 Aug 2012 18:47

I am using PIC18F26K22 and Newhaven Display NHD-14432WG-BTFH-V#T Glcd with
ST7920 controller.

Since Mikro C for PIC does not have any funtions for this display I went
looking to see how I could write a string to the display.

I came up with the code I show here. It works but I am not sure why.
Normally if I wanted to display a "T" I would look up the built in character
codes for it, 0x54, and send it to the display with Dat(0x54);

I don't see how the code I have come up with finds the codes to display
can anyone explain it to me?

Code: Select all

{GLCD_DataPort = N;
 GLCD_RS = 1;
 GLCD_EN = 1;
 Delay_ms(1);   
 GLCD_EN = 0;
}
//------------------------------------------------------------------------
void Com(char N) //SEND DATA TO GLCD
{GLCD_DataPort = N;
 GLCD_RS = 0;
 GLCD_EN = 1;
 Delay_ms(1);   //>140 nano SECONDS
 GLCD_EN = 0;
}
//-------------------------------------------------------------------------
// Write a string to GLCD WITH ST7920 CONTROLLER
void SendStr(unsigned char *ptString) 
{
  while((*ptString)!='\0') //'\0' is a n ull char automatically added to 
                          //string if in double quotes
  {
   Dat(*ptString++); //INCREMENT THE STRING POINTER AND SEND CHAR TO DISPLAY
  }
}

//------------------------------------------------------------------------
while(1)
  {Com(0x30); //BASIC INSTRUCTION SET
   Com(0x80); //1ST LINE  //START OF FIRST LINE
   SendStr("0123456789ABCDEFGH");
  }
//-------------------------------------------------------------------------


pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

Re: GLCD WITH ST7920 CONTROLLER

#2 Post by pwdixon » 30 Aug 2012 19:01

It works because the display controller has a built-in the font table.

pumper
Posts: 277
Joined: 10 Jan 2011 17:37

Re: GLCD WITH ST7920 CONTROLLER

#3 Post by pumper » 30 Aug 2012 19:57

I know it has the built in table but if I write Dat("T"); it won't display a "T". I have to tell it Dat(0x54);
I guess if I point to the location where I saved "T" it would find the ASCII code for it but it doesn't know what to do with "T".

hexreader
Posts: 1784
Joined: 27 Jun 2010 12:07
Location: England

Re: GLCD WITH ST7920 CONTROLLER

#4 Post by hexreader » 30 Aug 2012 20:26

pumper wrote:I know it has the built in table but if I write Dat("T"); it won't display a "T". I have to tell it Dat(0x54);
I guess if I point to the location where I saved "T" it would find the ASCII code for it but it doesn't know what to do with "T".
"T" is a string consisting of 2 bytes 0x54 and 0x00.

Try 'T' which should produce a single character, without a null terminator.
Start every day with a smile...... (get it over with) :)

pumper
Posts: 277
Joined: 10 Jan 2011 17:37

Re: GLCD WITH ST7920 CONTROLLER

#5 Post by pumper » 30 Aug 2012 21:00

That's what I like about this forum, I learn something from every post.

pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

Re: GLCD WITH ST7920 CONTROLLER

#6 Post by pwdixon » 30 Aug 2012 21:31

I hadn't noticed before but where is the function Dat?

pumper
Posts: 277
Joined: 10 Jan 2011 17:37

Re: GLCD WITH ST7920 CONTROLLER

#7 Post by pumper » 30 Aug 2012 23:00

Looks like I cut it off it is first in the code, here it is again but complete this time.

Code: Select all

void Dat(char N) //SEND DATA TO GLCD
{GLCD_DataPort = N;
 GLCD_RS = 1;
 GLCD_EN = 1;
 Delay_ms(1);   
 GLCD_EN = 0;
}

pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

Re: GLCD WITH ST7920 CONTROLLER

#8 Post by pwdixon » 31 Aug 2012 06:08

Thanks

Post Reply

Return to “mikroC PRO for PIC General”