5989 views|7 replies

62

Posts

0

Resources
The OP

[Seeking advice] A read and write problem of LCD CGRAM [Copy link]

My controller is T6963, and I can see Chinese characters in text mode. The following is a piece of my code:
  1. /******************************************************************************** Function: Write the font pattern (32 bytes) of a word pointed to by str into CGRAM Parameter: str points to the first address of the font pattern array /*************************************************************************/ void Write2CG( unsigned char *str ) { unsigned char i; unsigned char charc; unsigned char DatL, DatH; unsigned char Coder = 0x80; //internal code in CGRAM unsigned char Offset= 0x0f; unsigned char temp1, temp2; WriteCmd3( 0x1f,0x00,0x22); //Set the address of CGRAM in the display cache to 0xf800 ~ 0xffff; temp1 = Coder>>4; temp2 = Offset<<4; DatH = (Offset<<4)|(Coder>>4); //The address in CGRAM is 0xF8oo ~ 0xffff; DatL = Coder<<3; WriteCmd3(DatL,DatH, 0x24); //Set the address pointer for( i="0"; i<32; i++ ) //Write the font into CGRAM. Automatically get the internal code 80h,81h,82h,83h { charc = *(str+i); WriteData( *(str+i) ); DatL++; WriteCmd3(DatL,DatH, 0x24); } } My function to display this Chinese character is: //Display Western characters void ShowText( unsigned char column, unsigned char lin, unsigned char hzcode ) { unsigned int StartAddr; StartAddr = lin*LineChar + column; // LineChar = 32; WriteCmd3( (unsigned char)(StartAddr&0xff),(unsigned char)(StartAddr>>8),0x24); WriteCmd2( hzcode,DataWAddrNV ); //Write the character with code hzcode, the address pointer remains unchanged} //My order of taking the font is abcd // column: column, lin: OK, hzcode: Chinese characters are divided into four parts, hzcode is its code, such as 0x80 void ShowHZ( unsigned char column, unsigned char lin, unsigned char hzcode ) { // lin=lin*8; ShowText(column,lin,hzcode); ShowText(column+1,lin,hzcode+1); ShowText(column,lin+1,hzcode+2); ShowText(column+1,lin,hzcode+3); }
复制代码
But the characters I display are garbled, and no matter what character I change the Chinese character font to, the garbled characters displayed are the same. I am depressed, is it possible that the font I made at the beginning was not stored at all? Thank you for your advice. One more thing to explain: if my lin=lin*8; is commented out, even the position display is wrong. Add lin=lin*8 to correctly locate the position on the display screen. But: In text mode, isn't the relationship between the display position (col, lin) and the video memory "video memory unit address = lin*32+col"? Also, in graphics mode, the relationship between the display position (col, lin) and the video memory is also "video memory unit address = lin*32+col", right? In text mode, (col, lin) is in units of 8x8 character bits, and in graphics mode, (col, lin) is in units of 8x1. Am I right?
This post is from Embedded System

Latest reply

for( i="0"; i  Details Published on 2009-2-16 09:27

80

Posts

0

Resources
2
First try to see if an arbitrary point can be displayed normally, and then make other programs based on this.
This post is from Embedded System

63

Posts

0

Resources
3
RE: sherlock_lai My function for displaying western characters is correct, so my function ShowHZ should also be correct. I think the problem may be in the function Write2CG. But where is the problem? Can't I just set the starting address of CGRAM and then write the fonts one by one?
This post is from Embedded System

72

Posts

0

Resources
4
Re: sherlock_lai Thank you for your ideas. I called ShowHZ (20, 4, 0x11); // 0x11 is the code of "1" in CGROM, and found that "1 4", 3 and a number 2 displayed by ShowHZ were garbled. It can be seen that this function is also different from my expectations. But it is not all garbled. Does this mean that Write2CG function also has problems?
This post is from Embedded System

58

Posts

0

Resources
5
I changed ShowHZ to the following:
  1. void ShowHZ( unsigned char column, unsigned char lin, unsigned char hzcode ) { ShowText(column,lin,hzcode); ShowText(column,lin+1,hzcode+1); ShowText(column+1,lin,hzcode+2); ShowText(column+1,lin+1,hzcode+3); }
复制代码
I changed the calling order of ShowText in the function. Now I called ShowHZ(20, 4, 0x11); //0x11 is the code for "1" in CGROM, and found that ShowHZ displayed "1 3", 2 4, etc. Why must it be displayed in the order of upper left, lower left, upper right, and lower right?
This post is from Embedded System

79

Posts

0

Resources
6
I wonder if you succeeded later? I have the same problem now, can you give me some advice?
This post is from Embedded System

72

Posts

0

Resources
7
Consider the timing when writing and whether a delay function is needed when writing? I have only worked with 1602 LCDs and found that when writing, if the position of the delay function is not right, garbled characters will appear. No matter how I do it, garbled characters will appear. Later, I adjusted the position of the delay function and it was fine.
This post is from Embedded System

59

Posts

0

Resources
8
for( i="0"; i<32; i++ ) //Write the font into CGRAM. Automatically get the internal code 80h, 81h, 82h, 83h Why do you need (i="0")????????????????????? "0" is the first address of the string "0"
This post is from Embedded System

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

    EEWorld
    subscription
    account

    EEWorld
    service
    account

    Automotive
    development
    circle

    Robot
    development
    community

    Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
    快速回复 返回顶部 Return list