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 CCS Technical Support

My GLCD not Work with 18F452. Work only with 16F877A

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Gerson



Joined: 22 Nov 2006
Posts: 5
Location: Colombia

View user's profile Send private message Send e-mail MSN Messenger

My GLCD not Work with 18F452. Work only with 16F877A
PostPosted: Wed Nov 22, 2006 10:16 pm     Reply with quote

Hi!. Excuseme for my bad English. (Speak Spain)

Executing the example of CCS, EX_GLCD.C @20Mhz in PIC18F452 don't work but work fine in PIC16F877. Test with new XTAL and new Capacitor 20pF and not change. Only garabage. The GLCD is GDM12864M, and work whit GLCD.C, KS0108_me_EP4.C drivers, but only with PIC16F877A.

The config fuses for PIC18F452 are:

#include <18F452.h>
#device adc=8

#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOOSCSEN //Oscillator switching is disabled, main oscillator is source
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES PUT //Power Up Timer
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOCPD //No EE protection
#FUSES NOCPB //No Boot Block code protection
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads

#use delay(clock=20000000)


setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_oscillator(False);

Really �Thank you for help me!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 24, 2006 3:47 pm     Reply with quote

Does the 18F452 work if you try a simple program, such as the one
shown below ? This program will blink an LED on Pin B0.
Code:

#include <18F452.h>
#fuses HS, NOWDT, PUT, BROWNOUT, NOLVP
#use delay(clock=20000000)
//===========================
void main()
{

while(1)
  {
   output_high(PIN_B0); // LED on
   delay_ms(500);
   output_low(PIN_B0);  // LED off
   delay_ms(500);
  }

}

Also, post your compiler version. This will be a number such as
3.236, or 3.249, or 4.012, etc. You can find the version number
at the start of the .LST file for your project. Look for the .LST file
in the project directory.
Gerson



Joined: 22 Nov 2006
Posts: 5
Location: Colombia

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Fri Nov 24, 2006 9:02 pm     Reply with quote

Hello PCM Programmer. Thank You for respond.

The compiler version is 4.013

Yes, Work fine with certain code with out LCD. Change the PIC for New and the problem persist. Only not work the part referent to GLCD.

Change for a other Power Supply, For a New crystal, asemble circuit in Printed Circuit Board, Program with PicStarPlus (Olimex), program with ICD1 (Olimex), program ICSP and Sockedted and the problem persist.

Use compiler into MPLAB v7.43 and the result is equal. Test with drivers glcd.c, hdm64gs12.c, ks0108_me_ep4.c. Tes with other code and examples, Test with reset conect to Vdd, direct and with 4k7, 10k, 47k resistor, Test with #define fast_glcd, etc, etc, etc.

Test the code in the proteus 6.9 and work fine.

#include "e:\MSDOC\W\000 - C-UG37[OK]\452\rx\ug37rx.h"
#include <hdm64gs12.c>
//#define fast_glcd

//#include <ks0108.c>


//------------------------------------------------------------------------------



void ver_datos(int d_0, int d_1, short int error_bit)
{
char texto[21];
char logo_[21]="SISTEMA UG37"; INT *logo=logo_;
char error_[21]="Error";int *error=error_;
char b0[8]= "B0"; int *b_0 = b0;
char b1[8]= "B1"; int *b_1 = b1;
int x,y;
int contador;

glcd_init(ON);
delay_ms(100);
glcd_fillScreen(off);


glcd_text57(0, 0, logo, 1, on);

x = 42; y = 18;


//Impresion en 10x15 de los datos recibidos
sprintf(texto, "%X", d_0); glcd_text57(x+24, y, texto, 2, on);//Dato_0
sprintf(texto, "%X", d_1); glcd_text57(x, y, texto, 2, on); //Dato_1

//Dibujar la linea horizontal inferior de los datos
glcd_line(x, y+17, x+20, y+17, on); //Dato_0
glcd_line(x+24, y+17, x+44, y+17, on); //Dato_1

//Dibujar linea vertical inferior
glcd_line(x+10, y+17, x+10, y+22, on); //Dato_0
glcd_line(x+34, y+17, x+34, y+22, on); //Dato_1

//Colocar las etiquetas de los datos en 5x7
glcd_text57(x+6, y+25, b_1, 1, on); //Dato_0
glcd_text57(x+30, y+25, b_0, 1, on); //Dato_1


if (error_bit == 0)
{
glcd_text57(0, 56, error, 1, on);
}

}

void main()
{
int d0,d1,error_bit;
int s;
int d,dato_0, dato_1;

//---------------------------------------------------------------------------

inicio:

output_high(ledr);delay_ms(1000);output_low(ledr);

d0=0x00; d1=0x00; error_bit=1;

ver_datos(d0,d1,error_bit);

//---------------------------------------------------------------------------

esperar_pulso:

if (input(rx)) //START BIT <<<------------
{
//output_high(ledv);delay_us(10);output_low(ledv); //Sincro Debugger (Ini del Start Bit)

for (s=0;s<80;s++)
{
delay_us(100);
if (!input(rx))goto esperar_pulso;
}


output_high(ledv);delay_us(10);output_low(ledv); //Sincro Debugger (Fin del Start Bit)

//Espero que caiga el pulso para empezar sicronizmo

esp_fin_start:

while(input(rx)) goto esp_fin_start;

//Comienza el bit de sincronismo y apunto al centro del mismo

output_high(ledv);delay_us(10);output_low(ledv); //Sincro Debugger (Start Sincronismo)
delay_us(1650);
//delay_ms(1);

//Comienzo a recibir los 16 datos

for (d=0;d<8;d++)
{
if(input(rx))bit_set(d0,d);
else bit_clear(d0,d);
delay_us(1030);
output_high(ledv);delay_us(10);output_low(ledv);//Sincro_Debugger Bit_Dato_0
}

//delay_us(1080);

for (d=0;d<8;d++)
{
if(input(rx))bit_set(d1,d);
else bit_clear(d1,d);
delay_us(1030);
output_high(ledv);delay_us(10);output_low(ledv);//Sincro_Debugger Bit_Dato_0
}

ver_datos(d0,d1,error_bit);

delay_ms(500);

output_low(ledv);



}

goto esperar_pulso;

}


[/img]


Very Tank You for Help Me.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 24, 2006 9:37 pm     Reply with quote

My first suggestion is (if possible) download vs. 3.249 of the compiler
and try that version.

You said it worked OK in Proteus, so that implies that it could be a
hardware problem. However, I still think the first thing you should
do is try it with vs. 3.249.
Gerson



Joined: 22 Nov 2006
Posts: 5
Location: Colombia

View user's profile Send private message Send e-mail MSN Messenger

Download v3249 and the problem persist !!!
PostPosted: Fri Nov 24, 2006 10:52 pm     Reply with quote

Ready! Download v 3.249, Compile and unchanged. The problem is the same.

Question??? HardWare Problem ??? But only for PIC18F452 ???

For what razon 16F877A, Work Fine and 18F452 not. Really misterious this problem.

Other idea???
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 25, 2006 12:36 am     Reply with quote

You need to post a complete program, that shows the problem.
The program must be compilable. So far, you have only posted
pieces of a program. I copied the pieces into MPLAB and tried
to compile it, but some parts are missing, and doesn't compile.

You need to post a compilable program.

For example, what is in this file ?
Quote:
ug37rx.h


Post a program that I can copy into MPLAB, and have it compile
with no errors.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Sat Nov 25, 2006 10:46 am     Reply with quote

The first thing I would do is correct the glcd.c driver. The driver ignores whether or not the device is busy. This can lead to problems. What you will notice is garbaged data on the display. From past experience, what I have seen is the MSB of the data byte being set. The reason for this is because the driver writes pixels. It must read the data currently there, modify it and then write it back. If the device is busy, when the data is read back, it will be invalid and thus create the garbage. You might also try slowing down the 18F452 as a test.
Gerson



Joined: 22 Nov 2006
Posts: 5
Location: Colombia

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Sun Nov 26, 2006 10:12 am     Reply with quote

Hello Mark !!

The first thing I would do is correct the glcd.c driver. ???

How ???

My experience in "C" or CCS is the only 2 month !

Make delay in the drivers of GLCD?. You have a driver correct for the GLCD ? Really very tank you for post your correct driver.

Hello PCM Programmer !!

All the codes with GLCD and 18F452 are problem in my CCS. (Or I'm?).

The following codework very fine with 877A. But not with 452. �The config for my GLCD is import ?

This pieze of driver show the config of pins.

//----------------------------------

#ifndef HDM64GS12
#define HDM64GS12

#ifndef GLCD_WIDTH
#define GLCD_WIDTH 128
#endif

#ifndef GLCD_CS1
#define GLCD_CS1 PIN_B2 // Chip Selection 1
#endif

#ifndef GLCD_CS2
#define GLCD_CS2 PIN_B1 // Chip Selection 2
#endif

#ifndef GLCD_DI
#define GLCD_DI PIN_B5 // Data or Instruction input
#endif

#ifndef GLCD_RW
#define GLCD_RW PIN_B4 // Read/Write
#endif

#ifndef GLCD_E
#define GLCD_E PIN_B0 // Enable
#endif

#ifndef GLCD_RST
#define GLCD_RST PIN_B3 // Reset
#endif

#define GLCD_LEFT 0
#define GLCD_RIGHT 1

#ifndef ON
#define ON 1
#endif

#ifndef OFF
#define OFF 0
#endif

//-----------------------------------


The code workin is:


#include "e:\MSDOC\W\SensoVolt\877A\SensoVolt_877.h"
#include <hdm64gs12.c>
#include <graphics.c>

#use i2c(MASTER, SDA=PIN_C4, SCL=PIN_C3)

#define ent pin_c1
#define esc pin_c0

//---------------------------------------------------------// Variables Globales


int1 am, pm;
int seg_act, min_act, hor_act, hor_act_y, hor_old_y=0, ampm;
char txt[3];


#int_TIMER1
void TIMER1_isr()
{

}//

void cls(){glcd_fillscreen(0);}

void leer_tiempo()
{

i2c_start();
i2c_write(0xd0);
i2c_write(0);
i2c_start();
i2c_write(0xd1);
seg_act = i2c_read();
min_act = i2c_read();
hor_act = i2c_read(0);
i2c_stop();

glcd_rect(116,0,127,8,yes,off); // Limpio segundos
glcd_rect(37,27,61,33,yes,off); // Limpio hora


am=0;pm=0;
if(bit_test(hor_act,5))
{
pm=1; glcd_pixel(49,32,on);ampm=12;
}//
if(!bit_test(hor_act,5))
{
am=1; glcd_pixel(49,29,on);ampm=0;
}//

//--------------------------------// Imprimo segundos
sprintf(txt,"%2X",seg_act);
glcd_text57(116,0,txt,1,on);


//--------------------------------// Imprimo minutos
sprintf(txt,"%2X",min_act);
glcd_text57(51,27,txt,1,on);

//--------------------------------// Imprimo horas

sprintf(txt,"%2X",0b00011111 & hor_act);
glcd_text57(37,27,txt,1,on);
if(!bit_test(hor_act,4)) // Si la hora es -10
{
glcd_rect(37,27,41,33,yes,off);// Borro el cero a la izq.
hor_act_y = hor_act & 0x0F; // Valor para la grafica
}//

if(bit_test(hor_act,4)) // Si la hora es + 10
{
hor_act_y = (10+(hor_act & 0x0F)); // Para la grafica
}//

//--------------------------------// Dibujo la grafica de hora

if (hor_act_y != hor_old_y)
{
hor_old_y = hor_act_y;
glcd_rect(44,38,60,62,yes,on);
glcd_rect(44,38,60,38+ampm+hor_act_y,yes,off);
}//

}


void configurar_pic()
{
setup_adc_ports(AN0_AN1_VREF_VREF);
setup_adc(ADC_CLOCK_INTERNAL);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_TIMER1);
disable_interrupts(GLOBAL);
glcd_init(on);glcd_fillscreen(0);
}//

void marco_01 (int x,y,color)
{
if(x > 119) x = 119; if(y > 54) y = 54;
glcd_rect (x, y, x + 8, y + 10, no, color);
}//

void marco_02 (int x, y, color)
{
int n;
glcd_rect (x, y, x + 28, y + 49, no, color);
glcd_line (x+6, y, x+6, y+49, on);
for (n=6; n<43;n+=6)
{
glcd_line(x+2, y+n, x+6, y+n, on);
}
glcd_pixel(x+1, y+24, on);

}//


void main()
{



char logo[] = "SensoVolt v.1.0";
char uno[]="1", dos[]="2", tres[]="3", cuatro[]="4";
char hora[]="Hora";
char menu_config[]="Menu Configurar";
configurar_pic();

inicio:
cls();

//------------------------------------------------------
equipo_01:
marco_01(1, 14, 1);
glcd_text57(3, 16, uno, 1, on);

//------------------------------------------------------
equipo_02:
marco_01(1, 27, 1);
glcd_text57(3, 29, dos, 1, on);


//------------------------------------------------------
equipo_03:
marco_01(1, 40, 1);
glcd_text57(3, 42, tres, 1, on);

//------------------------------------------------------
equipo_04:
marco_01(1, 53, 1);
glcd_text57(3, 55, cuatro, 1, on);

//------------------------------------------------------
grafica_hora:
glcd_rect (35, 25, 63, 63, no, on);
glcd_line (35, 36, 63, 36, on); //Div Hor
glcd_line (41, 36, 41, 63, on); //Div Vert
glcd_line (37, 43, 41, 43, on); //Escala 1
glcd_line (35, 49, 41, 49, on); //Escala 2
glcd_line (37, 56, 41, 56, on); //Escala 3

//------------------------------------------------------
grafica_voltaje:
marco_02 (67, 14, 1);

//------------------------------------------------------
grafica_temperatura:
marco_02 (99, 14, 1);


//-------------------------------------------------------
glcd_text57 (0, 0, logo, 1, on);
glcd_line (0, 10, 127, 10, on);
glcd_text57 (38, 16, hora, 1, on);
delay_ms(650);


StandBy:

leer_tiempo();

if(!input(esc))goto menu_configurar;



delay_ms(100);

goto StandBy;


//------------------------------------------------------- Menu Configurar

Menu_Configurar:

glcd_fillscreen(0);
glcd_line (0, 10, 127, 10, on);
glcd_text57 (0, 0, menu_config, 1, on);
delay_ms(1000);

while(input(esc))
{

}


hor_old_y=0; //Para actualizar barra de la hora
goto inicio;



}//




This is SensoVolt.h



#include <16F877A.h>
//#device *=16
#device adc=10

#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected

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




Than You for Help me to Every One!!!
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Sun Nov 26, 2006 10:55 am     Reply with quote

Here is an example of what I mean. You will need to implement it yourself.

Code:

void GLCD_StrobeEnable(void)
{
   GLCD_E_SetVal();       
   asm
   {
     nop                               
     nop                               
     nop                               
     nop                               
     nop                               
   }
   GLCD_E_ClrVal();     
}

void GLCD_WaitBusy(void)
{
  uint8_t status;

  GLCD_Data_SetDir(FALSE);
        
  GLCD_DI_ClrVal();                 // Set for instruction
  GLCD_RW_SetVal();      // Set for reading
  asm
  {
    nop                               
    nop                               
    nop                               
  }

  while (1)
  {
    GLCD_E_SetVal();       
    asm
    {
      nop                               
      nop                               
      nop                               
      nop                               
      nop                               
    }
    status = GLCD_Data_GetVal();          // Get the data from the display
    GLCD_E_ClrVal();
    // Check the busy flag
    if ((status & 0x80) == 0)
      break;
    asm
    {
      nop                               
      nop                               
      nop                               
      nop                               
      nop                               
      nop                               
    }
  }
  GLCD_RW_ClrVal();      // Set for reading
}

void GLCD_InstructionWrite(bool side, uint8_t Instruction)
{
  if(side)                  // select the side of the display
    GLCD_CS2_SetVal();
  else
    GLCD_CS1_SetVal();
   
  GLCD_WaitBusy();
   
  GLCD_DI_ClrVal();                      // Set for instruction
   
  GLCD_Data_SetDir(TRUE);

  GLCD_RW_ClrVal();         // clear for writing

  GLCD_Data_PutVal(Instruction);   // send the instruction

  GLCD_StrobeEnable();

  GLCD_RW_SetVal();

  GLCD_Data_SetDir(FALSE);

  GLCD_CS1_ClrVal();      // deselect the chip select lines
  GLCD_CS2_ClrVal();
}

void GLCD_DataWrite(bool side, uint8_t data)
{
  if(side)                  // select the side of the display
    GLCD_CS2_SetVal();
  else
    GLCD_CS1_SetVal();
   
  GLCD_WaitBusy();
   
  GLCD_DI_SetVal();                     // Set for data
   
  GLCD_RW_ClrVal();         // clear for writing

  GLCD_Data_SetDir(TRUE);

  GLCD_Data_PutVal(data);   // send the data

  GLCD_StrobeEnable();

  GLCD_RW_SetVal();

  GLCD_Data_SetDir(FALSE);

  GLCD_CS1_ClrVal();      // deselect the chip select lines
  GLCD_CS2_ClrVal();
}

uint8_t GLCD_DataRead(bool side)
{
  uint8_t retval;                 

  GLCD_Data_SetDir(FALSE);
  if(side)                   // select the side of the display
    GLCD_CS2_SetVal();
  else
    GLCD_CS1_SetVal();

  GLCD_WaitBusy();

  GLCD_RW_SetVal();      // Set for reading
  GLCD_DI_SetVal();      // Set for data
  GLCD_E_SetVal();       // Pulse the enable pin
  asm
  {
    nop                               
    nop                               
    nop                               
    nop                               
    nop                               
  }
  retval = GLCD_Data_GetVal();          // Get the data from the display
  GLCD_E_ClrVal();
  GLCD_CS1_ClrVal();      // Reset the chip select lines
  GLCD_CS2_ClrVal();
  return retval;               // Return the read data
}

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 26, 2006 2:20 pm     Reply with quote

Your program is too complicated for a test program. I would delete
about 95% of your code, and make a small test program. Then it's
possible that the problem could be found.
someone
Guest







PostPosted: Mon Nov 27, 2006 5:32 am     Reply with quote

Hi

Please try to increase the value in the command 'delay_cycles(value)' in the driver file 'HDM64GS12.c' so e.g if the command is 'delay_cycles(5)' in the driver then change is to 'delay_cycles(10)'

Hope this helps

Best Regards
Gerson



Joined: 22 Nov 2006
Posts: 5
Location: Colombia

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Thu Jan 11, 2007 10:34 pm     Reply with quote

Hi! Very tank you for tour help!!!

The solution for my problem is increase the time in the GLCD library.

Very tank You Mark and Someone
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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