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

18F442 and LCD.C not works

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



Joined: 20 Jan 2005
Posts: 43

View user's profile Send private message

18F442 and LCD.C not works
PostPosted: Fri Mar 18, 2005 8:38 am     Reply with quote

PCWH 3.221

My lcd don't work !,
The hardware is ok, I tested it by asm routine
Where is the error in my code?
Thanks!

Code:


  struct lcd_map {               //   This structure is overlayed
         int     data : 4;
         boolean D4; // non usato per lcd
         boolean D5; // non usato per lcd
         boolean D6; // non usato per lcd
         boolean D7;


                   } lcd;

#byte lcd=0xf83
#byte PORTC=0xf82
#BIT RS= PORTC.5
#BIT E= PORTC.6

restart_wdt();


#define lcd_type 2           // 0=5x7, 1=5x10, 2=2 lines
#define lcd_line_two 0x40    // LCD RAM address for the second line

byte CONST LCD_INIT_STRING[4] = {0x20 | (lcd_type << 2), 0xc, 1, 6};




                             // The following are used for setting
                             // the I/O port direction register.

STRUCT lcd_map const LCD_WRITE = {0,0,0,0,0}; // For write mode all pins are out


void lcd_send_nibble( byte n ) {
      lcd.data = n;
      delay_us(10) ; //2
RESTART_WDT();
  output_high(PIN_C6);
      delay_us(10); //2

  output_low(PIN_C6);
}


void lcd_send_byte( byte address, byte n ) {
RESTART_WDT();

      rs = 0;
   delay_us(50);   
     rs = address;
      delay_us(25);//2


      delay_us(15); //2
  output_low(PIN_C6);
      lcd_send_nibble(n >> 4);
      lcd_send_nibble(n & 0xf);


}


void lcd_init() {
    byte i;

    set_tris_C(LCD_WRITE);
    set_tris_D(LCD_WRITE);

    rs = 0;

  output_low(PIN_C6);
    delay_ms(50);
RESTART_WDT();
    for(i=1;i<=3;++i) {
       lcd_send_nibble(3);
       delay_ms(5); //5

    }
    lcd_send_nibble(2);
    for(i=0;i<=3;++i)
       lcd_send_byte(0,LCD_INIT_STRING[i]);

}


void lcd_gotoxy( byte x, byte y) {
   byte address;

   if(y!=1)
     address=lcd_line_two;
   else

     address=0;
   address+=x-1;
   lcd_send_byte(0,0x80|address);
RESTART_WDT();
}

void lcd_putc( char c) {
 switch (c) {
     case '\f'   : lcd_send_byte(0,1);
                   delay_ms(2);
               break;
     default     : lcd_send_byte(1,c);     break;
   }



}
Mark



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

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

PostPosted: Sat Mar 19, 2005 7:52 pm     Reply with quote

Take a look at this and change the pins to match your connections

http://www.ccsinfo.com/forum/viewtopic.php?t=20182
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