LCDInfo.com

http://www.lcdinfo.com
It is currently Thu Mar 28, 2024 11:52

All times are UTC + 2 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: init t6963c
PostPosted: Wed Nov 14, 2007 13:32 
Offline

Joined: Wed Nov 14, 2007 13:16
Posts: 3
Hi :)

I'm trying to program a lcd with a t6963c controller. In initialization theres a thing that i can't understand, how you know the area and text home address set. The data sheet isn't clear and and i don't find nothing explicit.
My lcd is a 128x64.

Thanks for the help and sorry for the English.
Silvia


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 18, 2007 15:55 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
Those are left for you to decide.

The display has some amount of RAM, often 8 or 32KB. Let's say you put the text home address to the address 0. The minimum size you need for this is number of character columns * number of character rows. So for 128x64 LCD with 8x8 font it would be 128/8*64/8 = 128. With 6x8 font it is more as you can calculate.

But as there usually is plenty of RAM available you can reserve for example 1KB for the text and place the graphics area starting from address 0x400 for example. For graphics with 8x8 font you need 128/8*64=1024 bytes. So you could place another graphics buffer starting from 0x800.

So the parameters in this example would be:
TEXT_HOME 0x000
GRAPHICS_HOME 0x400

Or another way to calculate the parameters:
Code:
BYTES_PER_ROW_TXT = xpixels/font_width;
BYTES_PER_ROW_GFX = xpixels/font_width;

T_BASE = 0x0000;
G_BASE = ypixels/8 * BYTES_PER_ROW_TXT;


  // Display init
  WriteData(T_BASE & 0xFF);   //Data1: LowAddress
  WriteData(T_BASE >> 8);     //Data2: HighAddress
  WriteCtrl(0x40);            //Command: 0x40 -> 01000000

  WriteData(BYTES_PER_ROW_TXT);  //Data1: Colums
  WriteData(0);              //Data2: 0
  WriteCtrl(0x41);           //Command: 0x41 -> 01000001

  WriteData(G_BASE & 0xFF);  //Data1: LowAddress
  WriteData(G_BASE >> 8);    //Data2: HighAddress
  WriteCtrl(0x42);           //Command: 0x42 -> 01000010

  WriteData(BYTES_PER_ROW_GFX);  //Data1: Colums
  WriteData(0);              //Data2: 0
  WriteCtrl(0x43);           //Command: 0x43 -> 01000011


You could also place the graphics area starting from 0x000 and the text area after the graphics area. As you wish.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 18, 2007 23:18 
Offline

Joined: Wed Nov 14, 2007 13:16
Posts: 3
Thanks for your answer

I think I understand almost everything, but don't understand why graphic need a 128/8 * 64=1024 bytes of RAM.

Now i have another problem, i'm trying to display just some text on my lcd, but it don't display what i want and display in wrong position.

lcd.c:
Code:
#include "lcd.h"

// Testar checking flow
void vLCD_BusyCheck( void )
{
     unsigned char data;
    LCD_DATA_TRIS = 0xFF;   // Inicializa LCD_DATA como entrada

   LCD_CD = 1;         // Instrucao de comando
   LCD_RD = 0;         // Define modo de leitura
   LCD_WR = 1;
   LCD_CE = 0;         // Habilita o LCD

   data = LCD_DATA;        // Lê um byte do display

   // Testa bits 0 e 1 e não faz nada enquanto estes nao forem os dois 1
   while ( data && 0x03 == 0 );   

   LCD_CE = 1;         // Desabilita o LCD
   LCD_RD = 1;

   LCD_DATA_TRIS = 0x00;   // Inicializa LCD_DATA como saida
}

// Envia uma instrução de controlo ou um dado para o LCD
void vLCD_Write( unsigned char hInstrucao, unsigned char bCD )
{
   vLCD_BusyCheck();

   // Coloca a instrucao ou os dados a escrever no display
   LCD_DATA = hInstrucao;
   
   if (bCD)
      LCD_CD = 1;         // Define escrita de uma instrução
   else
      LCD_CD = 0;         // Define escrita de dados
   LCD_WR = 0;            // Define modo de escrita   
   LCD_RD = 1;
   LCD_CE = 0;            // Habilita o LCD
   Nop();
   LCD_CE = 1;            // Desabilita o LCD
   LCD_WR = 1;
}

// Envia um endereço para o LCD
void vLCD_WriteAddr( unsigned int hAddr, unsigned char hCmd )
{
   vLCD_Write(hAddr && 0x00FF, 0);   // Escreve byte low do endereco
   vLCD_Write(hAddr >> 8, 0);      // Escreve byte high do endereco
   vLCD_Write(hCmd, 1);         // Escreve instrução de comando
}

// Inicializa display.
void vLCD_Init( void )
{
   LCD_RST = 0;      // Faz o reset
   Delay100TCYx(50);   // Espera 1ms
   LCD_RST = 1;

   // Mode set
   vLCD_Write(0x80, 1);      // Modo OR
   // Control word set
   vLCD_WriteAddr(lcd_th, 0x40);   // Endereco inicial da area de texto
   vLCD_WriteAddr(lcd_ta, 0x41);   // Area de texto
   // Display mode
   vLCD_Write(0x94, 1);   // Selecciona modo de texto sem cursor

   vLCD_ClearText();         // Apaga area de texto
}

// Apaga area de texto
void vLCD_ClearText( void )
{
   int i=0, j=0;

   vLCD_WriteAddr(lcd_th, 0x24);
   for ( i=0;i<15;i++ )
      for ( j=0;j<7;j++)
         vLCD_WriteChar(' ');
}

// Escreve um caracter no LCD
void vLCD_WriteChar( unsigned char hLetra )
{
   vLCD_Write(hLetra - 0x20, 0);
   vLCD_Write(0xC0, 1);
}

// Indica o endereço para escrita ou leitura da ram
void vLCD_GotoXY(unsigned char x, unsigned char y)
{
   unsigned int addr;
   
   addr = lcd_th + y*lcd_ta + x;
   vLCD_WriteAddr(addr, 0x24);
}

void main(void)
{

   TRISEbits.PSPMODE = 0;         // Inicializa PORTD como I/O digitais
   LCD_CTRL_TRIS = 0b00000011;   // Inicializa pinos de controlo como saidas
   LCD_DATA_TRIS = 0x00;      // Inicializa LCD_DATA como saida
    LCD_LED = 1;

   
   vLCD_Init();
   LCD_LED = 0;

 //     vLCD_GotoXY(0, 0);
   vLCD_WriteAddr(0x0000, 0x24);
   vLCD_WriteChar('0');
//      vLCD_GotoXY(1, 0);
   vLCD_WriteAddr(0x0002, 0x24);   
   vLCD_WriteChar('1');
//      vLCD_GotoXY(0, 1)
   vLCD_WriteAddr(0x0010, 0x24);   
   vLCD_WriteChar('4');

   while(1);
}



lcd.h:
Code:
#include <p18f4520.h>
#include <delays.h>

#pragma config OSC = HS      // Oscilador do tipo "High-Speed Crystal/Resonator"
#pragma config WDT = OFF   // Watchdog Timer
#pragma config LVP = OFF   // Low Voltage ICSP


// Pino C/D (Register Select)
#define LCD_CD   LATCbits.LATC6   // LCD_CD = 0 -> Entrada de dados
                  // LCD_CD = 1 -> Entrada de instrucoes de comando

// Pino WR (Write)
#define LCD_WR   LATCbits.LATC3   // LCD_WR = 0 -> Escrita no LCD

// Pino RD (Read)
#define LCD_RD   LATCbits.LATC4   // LCD_RD = 0 -> Leitura do LCD

// Pino CE (Enable)
#define LCD_CE   LATCbits.LATC5   // LCD_CE = 0 -> Display fica habilitado

// Pino RST (Reset)
#define LCD_RST   LATCbits.LATC7   // LCD_RST = 0 -> Faz o reset

// Led indicativo do processo de inicializacao
#define LCD_LED LATCbits.LATC2      // LCD_LED = 1 -> Inicializacao do LCD

// Pinos DB0..DB7
#define LCD_DATA   LATD

// Defenicao das entradas e saidas
#define LCD_CD_TRIS      TRISCbits.TRISC6   // LCD_.._TRIS = 0 -> Saida
#define LCD_WR_TRIS      TRISCbits.TRISC3   // LCD_.._TRIS = 1 -> Entrada
#define LCD_RD_TRIS      TRISCbits.TRISC4
#define LCD_CE_TRIS      TRISCbits.TRISC5
#define LCD_RST_TRIS   TRISCbits.TRISC7
#define LCD_CTRL_TRIS   TRISC
#define LCD_DATA_TRIS   TRISD

#define lcd_th  0x0000      // Endereço inicial da area de texto
#define lcd_pixel_x  128               // Largura do display
#define lcd_pixel_y  64                  // Altura do display
#define lcd_caracter_x  8               // 6x8 -> 6; 8x8 -> 8
#define lcd_ga  lcd_pixel_x/lcd_caracter_x   // Area grafica (bytes usados por linha)
#define lcd_ta  lcd_ga                  // Area de texto (bytes usados por linha)

// Testar checking flow
void vLCD_BusyCheck( void );

// Envia uma instrução ou um dado para o LCD
// Variaveis de entrada: hInstrucao -> Instrução a enviar ao LCD
//               bCD -> Comando (1) ou dados (0)
void vLCD_Write( unsigned char hInstrucao, unsigned char bCD );

// Envia um endereço para o LCD
// Variaveis de entrada: hAddr -> Endereço
//               hCmd -> Instrucao de comando
void vLCD_WriteAddr( unsigned int hAddr, unsigned char hCmd );

// Inicializa display.
void vLCD_Init( void );   

// Apaga area de texto
void vLCD_ClearText( void );

// Escreve um caracter no LCD
// Variaveis de entrada: hletra -> Caracter a enviar ao LCD
void vLCD_WriteChar( unsigned char hletra );

// Indica o endereço para escrita ou leitura da ram
void vLCD_GotoXY(unsigned char x, unsigned char y);



I'm trying to write:

01...
4
.
.
.

But i'm write:

04...
4
.
.
.

I don't understand why!

Thanks for your help


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 11:02 
Offline

Joined: Wed Nov 14, 2007 13:16
Posts: 3
Hi!

Everything is fine now. Later i'll put here the final code.
Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group