CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

I'm in big trouble with VT162B/B LCD
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
moronilehi



Joined: 16 Jul 2009
Posts: 8
Location: chile

View user's profile Send private message MSN Messenger

I'm in big trouble
PostPosted: Thu Jul 16, 2009 11:27 pm     Reply with quote

Hi I am new to this whole world of microcontrollers and is the first time as I write English, and will not use a translator. My next concern is to buy an LCD VT162B / B alleged that his mind was consistent with S6A0069. Well I had problems with compatibility with many LCD and tried lcd driver of this page and other pages to be run my lcd where I worked and still does not work for me. After almost losing hope that I had asked to help the store where purchased and they sent me a file and datasheets of this model (do not accept returns jijjii). Well they sent me a library that supposedly works with the LCD VT162B / B, which supposedly supports the CCS compiler. Well it compiles the file with the CCS program and I get a compiler error message with the following statement.
Code:

# byte PORTD = DataBus / / DEFINE DATA BUS
# byte Tris_DataBus = TRISD / / TRIS DEFINE DATA BUS
# byte PORTE = ControlBus / / DEFINE CONTROL BUS
# byte = Tris_ControlBus TRIS / / TRIS DEFINE THE BUS CONTROL

I am using the CCS compiler 4.08 and pic16f874A do not know if the seller sent me a code for any street internet please help me thank you for your understanding. I am a newbie and I need to work for a school project.
PS Here's the code that sent me to the store if your use the LCD file without leaving the error would be grateful if you send me some examples:
Code:

////////////////////////////////////////////////////////////////////////////////
//                                   LCD.H                                                                                      //
//                                                             VERSION   2.1                                                                                 //
//                                                              JULIO 2009                                                                                 //
//                                                                                                                                                               //
//////////////////////////////////////////////////////////////////////////////////
#nolist

                                             // DEFINICION DE CONSTANTES PARA USO EN FUNCIONES
#define HOME               0x02      // PARA PONER CURSOR EN LA POSICION 0 DEL DISPLAY. USAR CON WRITE_LCD_COM
#define INCREASE         0x02      // INCREMENTA CURSOR. USAR CON LCD.ID
#define DECREASE         0x00      // DECREMENTA CURSOS. USAR CON LCD.ID
#define SHIFT_ON         0x01      // SHIFT DISPLAY. USAR CON LCD.SHIFT
#define SHIFT_OFF         0x00      // NO SHIFT DISPLAY. USAR CON LCD.SHIFT
#define LCD_ON            0x04      // ACTIVA LCD. USAR CON LCD.MODE
#define LCD_OFF            0x00      // DESACTIVA LCD. USAR CON LCD.MODE
#define CURSOR_ON         0x02      // ACTIVA CURSOR. USAR CON LCD.CURSOR
#define CURSOR_OFF      0x00      // DESACTIVA CURSOR. USAR CON LCD.CURSOR
#define BLINK_ON         0x01      // ACTIVA PARPADEO DEL CURSOR. USAR CON LCD.BLINK   
#define BLINK_OFF         0x00      // DESACTIVA PARPADEO DEL CURSOR. USAR CON LCD.BLINK   
#define BUS_8               0x10      // DEFINE BUS DE 8 BITS. USAR CON LCD.INTERFASE
#define BUS_4               0x00      // DEFINE BUS DE 4 BITS. USAR CON LCD.INTERFASE
#define CLEAR               0x01      // LIMPIA DISPLAY. USAR CON FUNCION WRITE_LCD_DATA()
#define NOCLEAR            0x00      // NO LIMPIA DISPLAY. USAR CON FUNCION WRITE_LCD_DATA()
#define   LINE1               0x00      // PRIMERA DIRECCION DE LINEA 1.
#define   LINE2               0x40      // PRIMERA DIRECCION DE LINEA 2.
#define   LINE3               0x14      // PRIMERA DIRECCION DE LINEA 3.
#define   LINE4               0x54      // PRIMERA DIRECCION DE LINEA 4.
#define LARGO               16         // Editar esta línea para indicar la cantidad de caracteres por línea del display
#define LINEAS            2            // Editar este línea para indicar la cantidad de líneas que dispone el display
#define   NULL               0x00

#list

struct
{
   char TEXT[LARGO+1];                  // define texto para escribir en lcd   
   int ID;                                    // define si el cursor de incrementará o decrementará
   int SHIFT;                              // define el shift del cursor
   int MODE;                                 // define si el display está ON ú OFF
   int CURSOR;                              // define si el cursor estará visible
   int BLINK;                              // define si el cursor parpadeará
   int INTERFASE;                        // define interfase de 4/8 bits
} lcd;

// CONFIGURAR AQUI LOS PUERTO QUE SE USARAN PARA BUS DE DATOS Y DE CONTROL
/*
#byte DataBus = PORTD               // DEFINE BUS DE DATOS
#byte Tris_DataBus = TRISD         // DEFINE TRIS DE BUS DE DATOS
#byte ControlBus = PORTE            // DEFINE BUS DE CONTROL
#byte Tris_ControlBus = TRISE   // DEFINE TRIS DEL BUS DE CONTROL
*/
#byte DataBus = PORTD               // DEFINE BUS DE DATOS
#byte Tris_DataBus = TRISD         // DEFINE TRIS DE BUS DE DATOS
#byte ControlBus = PORTE            // DEFINE BUS DE CONTROL
#byte Tris_ControlBus = TRISE   // DEFINE TRIS DEL BUS DE CONTROL

// GENERA PULSOS DE ESCRITURA PARA COMANDOS DEL DISPLAY Y SACA DATO
void WriteLcdComData(int x)
{
   Tris_ControlBus = 0xF8 & Tris_ControlBus;
   Tris_DatalBus = 0x00;
   DataBus = ControlBus = 0x00;
   ControlBus = 3;
   ControlBus = 0;
   ControlBus = 4;
   DataBus = x;
   ControlBus = 0;
   ControlBus = 3;
   delay_us(50);
}

// LIMPIA DISPLAY
void ClearLcd(void)
{
   WriteLcdComData(CLEAR);               // display clear
   delay_ms(2);
}

// INICIALIZA EL EL DISPLAY
 void IniLcd(void)
{
   delay_ms(20);
   WriteLcdComData(0x30);
   delay_ms(5);   
   WriteLcdComData(0x30);
   delay_us(150);
   WriteLcdComData(0x30);   
}

// CONFIGURA EL DISPLAY. LOS DATOS PARA LA CONFIGURACION DEBEN SER PUERTOS ANTES DE LLAMAR
// A ESTA FUNCION. LOS DATOS SON PARTE DE LA ESTRUCTURA LCD.
void SetupLcd(void)
{
   WriteLcdComData(0x04 | lcd.ID | lcd.SHIFT);                              //ENTRY MODE SET
   WriteLcdComData(0x08 | lcd.MODE | lcd.CURSOR | lcd.BLINK);      // DISPLAY ON OFF
   WriteLcdComData(0x28 | lcd.INTERFASE);                                    // SET FUNCTION
}

// ESCRIBE DATOS EN EL DISPLAY. X REPRSENTA DESDE QUE DIRECCIÓN DEL DISPLAY SE DESEAN ESCRIBIR LOS DATOS
// E Y INDICA SE SE LIMPIARÁ EL DISPLAY ANTES DE ESCRIBIR
// SI C = CLEAN, EL DISPLAY ES LIMPIADO
// SI C = NOCLEAN, SOLO SE ESCRIBEN LOS DATOS DESDE LA POCISION ESPECIFICADA POR POS
// LOS DATOS A ESCRIBIR DEBE SER COPIADOS PREVIAMENTE EN EL ELEMENTO LCD.TEXT DE LA ESCTRUCTIRA LCD
void WriteLcd(int pos, int c)
{
   int *p;
   Tris_ControlBus = 0xF8 & Tris_ControlBus;
   Tris_DatalBus = 0x00;
   DataBus = ControlBus =0x00;
   if (c)
      {
         clear_lcd();
         delay_ms(2);
      }
   pos|= 0x80;
   WriteLcdComData(pos);
   p = lcd.TEXT;
   for (; *p!=NULL; p++)
   {   
      DataBus = 0xff;
      ControlBus = 2;
      ControlBus = 1;
      ControlBus = 5;
      DataBus = *p;
      ControlBus = 1;
      ControlBus = 2;
      delay_us(50);
   }
}

void PutcLcd(int ini, char data)
{
   if (ini != CURRENT)
      {
         ini|= 0x80;
         WriteLcdComData(ini);
      }
   Tris_ControlBus = 0xF8 & Tris_ControlBus;
   Tris_DatalBus = ControlBus = 0x00;
   DataBus = 0xff;
   ControlBus = 2;
   ControlBus = 1;
   ControlBus = 5;
   DataBus = data;
   ControlBus = 1;
   ControlBus = 2;
   delay_us(50);
}

void ClearLcdLine(int x)
{
   int y;
   for (y=0; y<=LARGO; y++)
      {
         lcd.TEXT[y] = ' ';
      }
   lcd.TEXT[++y] = NULL;
   switch (x)
      {
         case 1   :   WriteLcd(LINE1,NOCLEAR);
                        break;
         case 2   :   WriteLcd(LINE2,NOCLEAR);
                        break;
         case 3  :   WriteLcd(LINE3,NOCLEAR);
                        break;
         case 4  :   WriteLcd(LINE4,NOCLEAR);
                        break;
         default :   break;
      }
}


Code:
// and the other part of the code is:
#include <16F877.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
//#FUSES WRT_50%                  //Lower half of Program Memory is Write Protected
#FUSES NOBROWNOUT               //No brownout reset

#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

#include <lcdvt162b.h>


void main()
{

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   IniLcd();
}
   while(true)
{
   WriteLcdComData("hola mundo");
 
   }
}

Sad Crying or Very sad
moronilehi@hotmail.com
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 17, 2009 12:35 am     Reply with quote

1. Post a list of the connections between the PIC pins and the LCD pins.

2. Also post a description of the contrast circuit that you have connected
to pin 3 of the LCD. Measure the voltage on pin 3 with a voltmeter.
What is it ?

3. Post if you have connected Ground to pin 1 of the LCD, and +5v to
pin 2 of the LCD.

4. Have ever made this PIC board do anything, such as blink an LED ?
Do you know that the PIC is working ?
moronilehi



Joined: 16 Jul 2009
Posts: 8
Location: chile

View user's profile Send private message MSN Messenger

PostPosted: Fri Jul 17, 2009 9:44 am     Reply with quote

Hello

I should mention that the program gave me a person of the company or manufacturer vtronic representative of this model LCD VT162B. This unique code is not found on the internet, so I told the man. yours can serve those who use this model of LCD and have compatibility problems.
1) that connect the pins as follows.
LCD PIC
D0-7 PORD / / Busdata
RS, RW and E  PORTE / / I m not specific to the individual company. In any case it is the buscontrol.

2) I had problem to run it. I have not had positive results.
This is the page where the information leaves the LCD datasheet:

http://rapidshare.com/files/256862751/vt162C_v1.0.pdf.html

I used to prove the Proteus and so I have an armed protoboard without result.
That is the connection to a potentiometer voltage V0.

Vdd ---- / \ / \ / \ / \ ---- V0--- / \ / \ / \ ---- Vss / /

3) use the connection scheme of the page:

http://www.vtronic.com.cn/products/images/VT162B-B.pdf

4) no signs of life through programs such as simulation proteus.
I do not work as described by the error comes at the beginning of the forum.
Problems with TRIS and PORT Sad .

Sincerely thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 17, 2009 10:26 am     Reply with quote

You did not answer the questions with enough information.

1. Post the exact pin to pin connections between the PIC and the LCD.
Give the pin numbers for each connection.


2. Measure the voltage on the V0 pin on the LCD. What is it ?
moronilehi



Joined: 16 Jul 2009
Posts: 8
Location: chile

View user's profile Send private message MSN Messenger

PostPosted: Fri Jul 17, 2009 11:32 am     Reply with quote

1) VO LCD pin 3 which governs the contrast.
VDD voltage at pin 2 positive lcd. vss negative voltage pin 1 on the lcd.
In summary
LCD PINS-------------------------------------------------micro controller pins
1 VSS Power ground --------------------------------------------- -
2 VDD Power supply ----------------------------------------- -
3 V0 Negative voltage for LCD driving ------------------------------------------------ -
4 RS Register selection input -------------------------------------------- RE2
5 R/W Read/write selection input ------------------------------------ RE1
6 E Enable signal input -------------------------------------------- RE0
7-14 DB0~DB7 Data bus -------------------------------------------- RB0-RB7 // según configuración de 4 o 8 bit
15 LED+A Led backlight anode

2) I give away with a variable resistance between 0 - 5 v V0 is the contrast of the LCD screen, as measured with the MultiTest delivery and the voltage in the range of 0 to 5v.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 17, 2009 11:45 am     Reply with quote

Try using the Flex LCD driver:
http://www.ccsinfo.com/forum/viewtopic.php?t=24661

Change the #define statements for the pins at the start of the Flex
driver code, to the pins shown below. This fits your hardware connections:
Code:

#define LCD_DB4   PIN_B4
#define LCD_DB5   PIN_B5
#define LCD_DB6   PIN_B6
#define LCD_DB7   PIN_B7

#define LCD_E     PIN_E0
#define LCD_RS    PIN_E2
#define LCD_RW    PIN_E1


Set the contrast voltage on pin V0 to be 0.5 volts.


Also, note that pins B6 and B7 are used by the ICD Debugger or
Programmer. After you have programmed the PIC, you need to
unplug the ICD connector from the PIC. The LCD and the ICD
can't share B6 and B7 at the same time.

It's easier if you use different pins than B6 and B7 for the LCD.
The Flex driver allows you to change the pins easily, after you
have changed the connections on your board.
Guest








PostPosted: Fri Jul 17, 2009 4:20 pm     Reply with quote

nothing happens. follow each step.
truth I'm already in despair over this situation Sad I will rebuke the classes Crying or Very sad . the screen is in black.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 17, 2009 4:34 pm     Reply with quote

Post your test program, that calls the Flex driver, and attempts to display
some text on the LCD.

Don't post the Flex driver, just post your test program. The program
should be very small, but complete, and it should be compilable with no
errors.

It should have the #include for the PIC, #fuses statement, #use delay(),
#include for the Flex driver, and main().
Guest








PostPosted: Fri Jul 17, 2009 4:42 pm     Reply with quote

Code:
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#include "flex_lcd.c"
   
//==========================
void main()
{
lcd_init();  // Always call this first.
while(1); {
lcd_putc("\hola mundo");
delay_ms(2000);
lcd_putc("\f");

}
}
moronilehi



Joined: 16 Jul 2009
Posts: 8
Location: chile

View user's profile Send private message MSN Messenger

PostPosted: Fri Jul 17, 2009 4:59 pm     Reply with quote

the probe in proteus simulator and it works fine but when I program the microcontroller only goes black LCD Screen Sad
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#include "flex_lcd.c"

//==========================
void main()
{
lcd_init(); // Always call this first.
while(1) {
lcd_putc("\hola mundo");
delay_ms(2000);
lcd_putc("\f");

}
}


Last edited by moronilehi on Fri Jul 17, 2009 5:04 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 17, 2009 5:00 pm     Reply with quote

Quote:
while(1); {

The semi-colon ; is blocking the program from entering the code inside
the braces. Remove it.


There is no way the program can "work fine" with that semi-colon in it.
moronilehi



Joined: 16 Jul 2009
Posts: 8
Location: chile

View user's profile Send private message MSN Messenger

PostPosted: Fri Jul 17, 2009 5:09 pm     Reply with quote

it had only copied a previous version inadvertently apology.had already corrected; but still not working
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 17, 2009 5:18 pm     Reply with quote

Always post the exact code that you are currently using.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 17, 2009 5:28 pm     Reply with quote

Have you ever made your hardware PIC board run any program before ?
Have you made it blink an LED ?
Do you know that your hardware board works ?

I don't see a link to your Proteus schematic anymore. It looks like
you removed the link.

Do you have a crystal installed on your hardware board (with the
associated capacitors) ?

Do you have a pull-up resistor on the MCLR pin ?

Any of these things can make the board fail to work, if they are missing.
moronilehi



Joined: 16 Jul 2009
Posts: 8
Location: chile

View user's profile Send private message MSN Messenger

PostPosted: Fri Jul 17, 2009 5:31 pm     Reply with quote

Sorry I am using a translator to write. You are a big help. Really. And I appreciate it Smile . What I meant is that the corrections requested but not yet working on lcd.
I do not know what can be Crying or Very sad
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group