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

troubles with GLCD display

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



Joined: 05 Jun 2006
Posts: 41
Location: Belgium

View user's profile Send private message Visit poster's website MSN Messenger

troubles with GLCD display
PostPosted: Sun Nov 22, 2009 10:15 am     Reply with quote

hello folks,
I have some trouble with a glcd, HQM1286404.
I am using this with the HDM64GS12.c driver.

All is running ok, but for some strange reason, the display switches after
some time to 1/2 and I can do nothing else than a displayinit(;) to become a normal display.

Resetting the display_unit is possible, but then I have a flickering display.

Any suggestions?
Code:

#include <18F452.h>

#fuses HS,WDT,NOLVP
#use delay(clock=1600000)   
#use i2c(SLAVE, SDA=PIN_C4, SCL=PIN_C3, address=0xa0,SLOW)
#include <HDM64GS12.c>
#include <graphics.c>
#include <math.h>


//////////////////////////////////////////////////////////
// global variables
//////////////////////////////////////////////////////////
   BYTE address, buffer[0x10];
      char TextSpanning[] =    "Spanning :";
      char TextStroom[]=       "Stroom   :";
      char Textvermogen[]=    "P     : ";
      char TextFrequentie[]=    "Hz    : ";
   unsigned int16    measU;
   unsigned int16   bargraph;
   unsigned int16     measI;
   unsigned int32    measPower;
   unsigned int16   Power;
   unsigned int32 Freq;
   unsigned int16    runstatus;
   char lcddata[20];
   int32 count,tel;
   int16 keyw;
   void Prnt_display();

      BYTE incoming, state;
   BYTE B1, B2, B3, B4;

////////////////////////////////////////////////////////////////////////////////
//******************************************************
#int_rtcc
void clock_isr()
{
   //disable_interrupts(GLOBAL);
   if (tel < 10)
      tel++;
      else
      {
         tel = 0;
         Prnt_display();
   //      enable_interrupts(GLOBAL);
      }
}
////////////////////////////////////////////////////////////////////////////////


#INT_SSP
void ssp_interupt ()
{
      state = i2c_isr_state();
    if(state <= 0x80)                     //Master is sending data
   {
      incoming = i2c_read();
         if(state == 3)                   
            keyw = incoming;
         if(state == 1)                 
            b1 = incoming;
         if(state == 2)                 
            b2 = incoming;
      
       if(keyw == 101)         
            {
//tempvar = make16(b2,b1);
         power = make16(b2,b1);
         keyw = 0;
         }
       if(keyw == 102)       
            {
         MeasU = make16(b2,b1);
         keyw = 0;
         }
       if(keyw == 103)         
            {
         MeasI = make16(b2,b1);
         keyw = 0;
         }
       if(keyw == 104)             
            {
         Freq = make16(b2,b1);
         keyw = 0;
         }
       if(keyw == 105)         
            {
         bargraph = make16(b2,b1);
         keyw = 0;
         }
       if(keyw == 106)                   
            {
         runstatus = make16(b2,b1);
         keyw = 0;
         }
       if(keyw == 111)       
             {
   //      D_CY = tempvar;
         keyw = 0;
         }
       if(keyw == 111)           
            {
   //      D_CY = tempvar;
         keyw = 0;
         }

   }
   if(state == 0x80)                     //Master is requesting data
   {
      i2c_write(buffer[address]);
   }
//   Prnt_display();
}



///////////////////////////////////////////////////////////////////////////////
void Prnt_display()
      {
          //   glcd_init(ON);
         glcd_rect(0, 0, 127, 63, NO, ON);           // Outline the display
         glcd_text57(3,  2, TextSpanning, 1, ON);     // Display "gemeten Spanning"
         glcd_text57(3, 12, TextStroom, 1, ON);      // Display "gemeten stroom"
         glcd_text57(3, 22, TextVermogen, 1, ON);    // Display "ingesteld vermogen"
         glcd_text57(3, 32, TextFrequentie, 1, ON);  // Display "Ingestelde Frequentie"
      
         // Zet gemeten spanning op display
         sprintf(lcddata,"%lu",MeasU);
         glcd_rect(65, 2, 126, 8, YES,OFF);         // oude waarde wissen
         glcd_text57(65,2,lcddata,1,on);

         // Zet gemeten stroom op display
         sprintf(lcddata,"%lu",measI);
         glcd_rect(65, 12, 126, 18, YES,OFF);         // oude waarde wissen
         glcd_text57(65,12,lcddata,1,on);

         // Zet ingesteld vermogen op display         
         sprintf(lcddata,"%lu",power);
         glcd_rect(45, 22, 79, 28, YES, OFF);         // oude waarde wissen
         glcd_text57(45,22,lcddata,1,on);
                  
         // Zet berekend vermogen op display   
         measpower = measU * (measI/1000.0);
         sprintf(lcddata,"%lu²²²",measPower);
         glcd_rect(80, 22, 126, 28, YES, OFF);         // oude waarde wissen
         glcd_text57(80,22,lcddata,1,on);

         sprintf(lcddata,"%lu",freq*10);
         glcd_rect(45, 32, 126, 38, YES, OFF);         // oude waarde wissen
         glcd_text57(45,32,lcddata,1,on);
         
   //      sprintf(lcddata,"%lu",keyw);
   //      glcd_rect(45, 42, 126, 48, YES, OFF);         // oude waarde wissen
   //      glcd_text57(45,42,lcddata,1,on);


         if (runstatus != 1)
                     {
                        glcd_rect(1, 52, 126, 58, YES, ON);         // oude waarde wissen
                     }
         else
                     {
                        // waarde mag varieren tussen 1 en 81
                        glcd_rect(1, 52, 126, 58, YES, OFF);         // oude waarde wissen
                        glcd_rect(1, 52, 126, 58, NO, ON);         // oude waarde wissen
                        glcd_line(63,52,63,58,ON);
                        glcd_line((1+(bargraph/33)),52,(1+(bargraph/33)),58,ON);
                     }

}
////////////////////////////////////////////////////////////////////////////////
void main()
{
      set_tris_a(0b11000001);
   //   setup_wdt(WDT_72MS);
      setup_counters(RTCC_internal,Rtcc_div_32 | Rtcc_8_bit);
      enable_interrupts(INT_RTCC);
       enable_interrupts(INT_SSP);
      enable_interrupts(GLOBAL);
      glcd_init(ON);                                // Must initialize the LCD
      while (TRUE)
      {

      //   Prnt_display();
         delay_ms(200);
         count++;
         if (count > 10)
            {
               count = 0;
            //   glcd_init(ON);                                // Must initialize the LCD
            }
         restart_wdt();//at least one in the main while(1) loop
         }   //end while(true)
}         //end void(main)

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 22, 2009 10:23 am     Reply with quote

Quote:

#include <18F452.h>

#fuses HS,WDT,NOLVP
#use delay(clock=1600000)

Look closely at your specified frequency. Does it match your crystal ?
Guest








PostPosted: Sun Nov 22, 2009 10:42 am     Reply with quote

Oops... i will test this ... Embarassed
Guest








PostPosted: Sun Nov 22, 2009 10:50 am     Reply with quote

I did change the freq... this was wrong,

now I see still flickering in the display.. it seems that wdt is working.

After changing WDT into NOWDT, the cpu hangs....
Maybe is this the problem i am struggling.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 22, 2009 1:44 pm     Reply with quote

Have you tested your LCD code and your i2c slave code separately ?

Make them work correctly as separate programs and then combine them.
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