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

LCD and PIC16F2620 problem

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



Joined: 28 May 2017
Posts: 80

View user's profile Send private message

LCD and PIC16F2620 problem
PostPosted: Sun May 05, 2024 10:05 am     Reply with quote

Hey. I have tried to solve this problem about two weeks.
I do level meter, but then I needed to use PIC18F2620.
It seems to be simple to replace PIC16F886.

My meter is here http://probyte.fi/LEVELMeter.jpg
and schematic is here http://probyte.fi/OK.jpg

I can't get simple LCD init to work.

I have tried with old (but PIC16) codes, changed to PIC18F code.
The LCD do not convert to 2 row and doesn't show any code.

How ever I have got LCDInit to work once, but I have not source code any more.
Have anybody a PIC18F and LCD code?
Or can you help me.

Pekka
Here is my code:
Code:


/*=============================================                                                                                 
Project: Angelmeter with Murata sensor   SCL3300-10
 LCD RC-2002A-BIW-ES  2*20 characters                                                                                                                   
 5V VCC
===================================================*/

#include <18F2620.h>
#device ADC=10
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT                //Code not protected from reading
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES PUT                      //Power Up Timer
#FUSES NOCPD                    //No EE protection
//#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 FCMEN                    //Fail-safe clock monitor enabled
#FUSES NOMCLR                   //Master Clear pin not enabled
#FUSES NOWRT
#fuses NOWDT                     //no  restart_wdt
#include "pic18reg.h" 
 
#use delay(clock=8000000, restart_wdt)   
#use rs232(baud=9600, parity=N,  xmit=PIN_C6, rcv=PIN_C7,errors, bits=8)  // RS232 asetukset
 
#define LCD_ROW1 0x80
#define LCD_ROW2 0xA8
#define LCD_ROW3 0xC0
 
#bit PWM_BIT = PORTC.2
#byte SSPCON1 =0xfc6
#bit SSPEN =SSPCON1.5 
 
#define CMD 0
#define DATA 1 
#BIT    DB3 = PORTB.3
#BIT    DB2 = PORTB.2
#BIT    DB1 = PORTB.1
#BIT    DB0 = PORTB.0
#BIT    RS = PORTB.4 
#BIT    ENABLE = PORTC.5   
 
 #include <string.h>
 #include <ctype.h>
#BIT    Underled = PORTC.0 
#BIT    SOUND = PORTC.2
 
#BIT   Overled = PORTC.3   
#define BUTTON PIN_B5   //button
 
#define PROS 0x25
#define EE_DELAY 3
#define EE_OFFSETHI 0
#define EE_OFFSETLO 1
#define EE_ANGLEMODE 4
#define EE_HYSTER  5
#define EE_TARGET 6
#define EE_TARGETDES  7
#define PAUSE_RELOAD 5
#define OFFSETVAL    PIN_A7
#define HYSTERVAL    PIN_A5
#define DISPLAYMODE  PIN_A4
#define DISPLAYTEMP  PIN_A3
#define DELAYVAL     PIN_A2
#define TARGETKUL    PIN_A1
 #INCLUDE <stdlib.h>

char LCDBuffer[26];
 
unsigned int8 delay;  // 
 
int count, pauseTime =25,onsound=1;
 
unsigned int8 counter;
 #define MAXCOUNT 5
int16 table[MAXCOUNT+1];
char c; //
void decode_message ( ) ;
void DisplayHyster();
int1 start=0;
void printlcd1();
void printLcd2();
void readsetup(void);
void clear_lcd();
 
#define lcd_type 2        // 0=5x7, 1=5x10, 2=2 lines
#define lcd_line_two 0x40 // LCD RAM ADdEss m
 
int8 const LCD_INIT_STRING[4] =
{
 0x20 | (lcd_type << 2), // Mode  4-bit, 2 rows = 0x28
 0xc,                    // dislay on
 1,                      // clear display
 6                       // move cusor pn step forwardsiirrä
 };
 
/*=============================

==========================*/
void lcd_send_nibble(int8 nibble)
{
 
 
 if ( nibble &1)
  DB0 =1;
  else
  DB0 =0;
   
 if ( nibble &2)
   DB1 =1;
   else
   DB1 =0;
   
 if ( nibble &4)
   DB2 =1;
 else
   DB2 =0;
     
 if ( nibble &8)
   DB3 =1;
  else
   DB3 =0;
  delay_us(1);
 
    set_tris_c(0);
  ENABLE =1;
  output_high( PIN_C5);
  delay_us(20);
 
  ENABLE =0;
    output_low( PIN_C5);
 
 
  delay_us(10);
 
}

/*==============================================
 

========================================*/
void lcd_send_byte(unsigned int8 ASCII_CHAR, unsigned int8 n)
{
 
RS=1;
ENABLE=1;

if(ASCII_CHAR)  // ASCII Data?
   
   RS=1;       // RS mode =1
 
else
   RS=0;       // RS_MODE =00  eli LCD command

delay_us(20);
ENABLE =0;
 
lcd_send_nibble(n >> 4);  // Ensin Hi nibble
lcd_send_nibble(n & 0xf); // siten LOW nibble
 
if(!ASCII_CHAR)
  delay_ms(1);
else
   delay_ms(1); // 60 us riittää
}

/**********************************
init LCD
 *********************************/
void lcd_init(void)
{
unsigned int8 i;

RS=0;   
ENABLE =0;
delay_ms(20);   
for(i=0 ;i < 3; i++)
   {
    lcd_send_nibble(0x03);
    delay_ms(10);
   }
 
 
lcd_send_nibble(0x02);


for(i=0; i < sizeof(LCD_INIT_STRING); i++)
   {
     
    lcd_send_byte(CMD, LCD_INIT_STRING[i]);

      delay_ms(10);

   }
 
}
void  row1( void) {
lcd_send_byte(CMD, LCD_ROW1);
}
 
/*void  row1_5( void) {
lcd_send_byte(CMD,  LCD_ROW1+8);
}
 */
void  row2( void) {
lcd_send_byte(CMD, LCD_ROW2);
}
void clear_lcd(void) {
   lcd_send_byte(CMD,1);    // clear LCD
}
                   
/*================       
Display
==============*/
void printlcd1( void) {
unsigned  int8 i=0;               
char c;
row1();
 
for ( i=0; i<strlen(LCDBuffer); i++) {
      c=LCDBuffer[i];
     lcd_send_byte(DATA,c);
     }
}

void printLcd2( void) {
unsigned  int8 i,c;
row2();
for ( i=0; i<strlen(LCDBuffer); i++) {
      c=LCDBuffer[i];
     lcd_send_byte(DATA,c);
 }

}
void  lcddelayTxtRow2  ( void) {
 
   sprintf(LCDbuffer, "Delay %ds         " , delay);
    printLcd2();// disply the rwault 2. row
}
 
// init Hardware
void initHardware ( void)
{
 setup_oscillator(OSC_8MHZ);
  restart_wdt();
 restart_wdt();
 setup_comparator( NC_NC_NC_NC);
 setup_spi(FALSE);   // THis must be before TRIS command !!
 port_b_pullups(TRUE);   //  INTCON2.7 =0
 set_pwm1_duty(520);
 set_tris_a(0b11111111);   
 set_tris_b(0b11100000); 
 set_tris_c(0b000001111);   
 // enable_interrupts(INT_RDA );
// enable_interrupts(INT_TIMER0);
// enable_interrupts(GLOBAL);
  setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256| RTCC_8_BIT);
  setup_timer_2(T2_DIV_BY_16,255,1);  // 
  pauseTime=0;
  count=0;
 setup_adc(  ADC_CLOCK_INTERNAL  );
 setup_adc_ports( AN0 | VSS_VDD  ); 
 set_adc_channel(0);
 SSPEN =0; 
 
}
 
 
 
#INT_RDA
void receive (void)
{
 
}
 
#int_timer0
void t0_isr(void) {
 
  if( count) {
    count--;
    return;
  }
 if(pausetime)
    --pausetime;
    else {
      pausetime=5;
      onsound= !onsound;
    }
 
}
 

void logo( void)
{
 sprintf( LCDBuffer,"Level meter");
 printlcd1();
 sprintf( LCDBuffer,"Probyte ");
 printLcd2(); 
 delay_ms(500);
}
/*********************************
 

**********************************/
void main(void)
{ int i;
 
 delay_ms(1);
 initHardware ();
 restart_wdt();
 Overled=1;   // leda off
 Underled=1;  // leda off
 counter=1;
 start =0; // arRT INTERRUPT
 count=0; //  h
 
 lcd_init(); // THE VEEY IMPORTANT FUCTION
   printf("\rLCD init end");
 for(i=0;i<MAXCOUNT;i++)
  table[i]=0;//
 
 while(1)
 {   
 logo ();
   delay_ms(500);
   printf("\rProgram start ");
 
 
}                                               
 

}

And PIC18reg.h is here
Code:

/*#include "pic18reg.h"
// 5.5.2024
*/
#byte DFLTCON = 0xF60
#BYTE CCP1CON = 0xFBD
#bit FLT3EN = DFLTCON.5
#BIT FLT2EN = DFLTCON.4
#BIT FLT1EN = DFLTCON.3

#BYTE CCPI1CON =0xFBE
#BYTE CCPI2CON =0xFBA
#BYTE PWM1CON =0xFB7
#BYTE T0CON = 0xFB5
#BYTE PORTA = 0x0F80
#BYTE PORTB = 0x0F81
#BYTE PORTC = 0x0F82
#BYTE PORTD = 0x0F83
#BYTE PORTE = 0x0F84
#BYTE TRISA = 0x0F92
#BYTE TRISB = 0x0F93
#BYTE TRISC = 0x0F94
#BYTE TRISD = 0x0F95
#bit TRIS5  =TRISC.5
#bit TRIS4  =TRISC.4
#BYTE LATB  = 0xF8A
// rekisteriportit
#BYTE LATA  = 0x0F89
#BYTE T3CON  = 0xFB1

int16       MAXCNT;
#byte       MAXCNT                = 0xF64
#byte       MAXCNTH               = 0xF65
#byte       MAXCNTL               = 0xF64

#BIT CCP1_INPUT =PORTC.2
#BIT CCP2_INPUT =PORTC.1

#byte       POSCNT    = 0xF66
#byte       POSCNTH  = 0xF67
#BYTE     POSCNTL  = 0xF66

#byte       VREG      = 0xF68
#byte       VREGH    = 0xF69
#byte       VREGL    = 0xF68
 

 
pekka1234



Joined: 28 May 2017
Posts: 80

View user's profile Send private message

LCD PIC18F2620
PostPosted: Sun May 05, 2024 10:24 am     Reply with quote

I have 5.115 version of CCS

Pekka
Ttelmah



Joined: 11 Mar 2010
Posts: 19326

View user's profile Send private message

PostPosted: Sun May 05, 2024 11:59 am     Reply with quote

Your code will probably not work, because you have an INT_RDA, that does
not call a getc inside. If this triggers your processor will be hung.
INT_RDA, cannot clear the interrupt, unless the character is read. So
if this gets called, it'll be called 'forever' and all other operations will
stop......

On the LCD code, there is standard code with the compiler, or use
PCM_Programmer's LCD code in the code library. This works and in
simple reliable code.
pekka1234



Joined: 28 May 2017
Posts: 80

View user's profile Send private message

PostPosted: Sun May 05, 2024 12:33 pm     Reply with quote

I deleted INT_RDA off, but it has no meaning
The serial code is following:

LCD init end
Program start
Program start
Program start
Program start
==
The CCS LCD example is quite different and much more complicated.
I have tried to use it but can't get it work.
But I try it again.
temtronic



Joined: 01 Jul 2010
Posts: 9160
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun May 05, 2024 2:08 pm     Reply with quote

#1 delete ALL WDT code !!! You do NOT need the WDT at this stage and it can cause all sorts of weird problems.

#2 I have used PCM P's LCD driver on PIC18F46K22 products for years. It WORKS.

#3 delete ALL timers and other code, not necessary and can cause 'problems'

Concentrate on getting the LCD to display properly. I call that the 'Hello World' program.

When that works, copy, rename and edit the new program for more code. That way you can go back to the WORKING 'Hello Program' and try again.
pekka1234



Joined: 28 May 2017
Posts: 80

View user's profile Send private message

PostPosted: Mon May 06, 2024 12:42 am     Reply with quote

Temtronic
Thank for help.
I removed all WDT functions and cleared other not used parameters
I tried to load it to my PCB, but it doesn't work.

[/code]

/*=============================================
Project: Angelmeter with Murata sensor SCL3300-10
LCD RC-2002A-BIW-ES 2*20 characters
5V VCC
code:lcd.c and pic18reg.c
===================================================*/
#include <18F2620.h>
#device ADC=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT //Code not protected from reading
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES BROWNOUT //Reset when brownout detected
#FUSES PUT //Power Up Timer
#FUSES NOCPD //No EE protection
#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 FCMEN //Fail-safe clock monitor enabled
#FUSES NOMCLR //Master Clear pin not enabled
#FUSES NOWRT
#include "pic18reg.h"

#use delay(clock=8000000)
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7,errors, bits=8) // RS232 asetukset

#define LCD_ROW1 0x80
#define LCD_ROW2 0xA8
#define LCD_ROW3 0xC0

#bit PWM_BIT = PORTC.2
#byte SSPCON1 =0xfc6
#bit SSPEN =SSPCON1.5

#define CMD 0
#define DATA 1
#BIT DB3 = PORTB.3
#BIT DB2 = PORTB.2
#BIT DB1 = PORTB.1
#BIT DB0 = PORTB.0
#BIT RS = PORTB.4
#BIT ENABLE = PORTC.5

#include <string.h>
#include <ctype.h>
#BIT Underled = PORTC.0
#BIT SOUND = PORTC.2
#BIT Overled = PORTC.3
#define BUTTON PIN_B5 //button
#INCLUDE <stdlib.h>
char LCDBuffer[26];
unsigned int8 delay; //
#define MAXCOUNT 5
char c; //

void printlcd1();
void printLcd2();
void clear_lcd();

#define lcd_type 2 // 0=5x7, 1=5x10, 2=2 lines
#define lcd_line_two 0x40 // LCD RAM ADdEss m

int8 const LCD_INIT_STRING[4] =
{
0x20 | (lcd_type << 2), // Mode 4-bit, 2 rows = 0x28
0xc, // dislay on
1, // clear display
6 // move cusor pn step forwardsiirrä
};

/*=============================

==========================*/
void lcd_send_nibble(int8 nibble)
{
if ( nibble &1)
DB0 =1;
else
DB0 =0;
if ( nibble &2)
DB1 =1;
else
DB1 =0;
if ( nibble &4)
DB2 =1;
else
DB2 =0;
if ( nibble &8)
DB3 =1;
else
DB3 =0;
delay_us(1);
set_tris_c(0);
ENABLE =1;
output_high( PIN_C5);
delay_us(20);

ENABLE =0;
output_low( PIN_C5);
delay_us(10);

}

/*==============================================


========================================*/
void lcd_send_byte(unsigned int8 ASCII_CHAR, unsigned int8 n)
{

RS=1;
ENABLE=1;

if(ASCII_CHAR) // ASCII Data?
RS=1; // RS mode =1
else
RS=0; // RS_MODE =00 or LCD command
delay_us(20);
ENABLE =0;
lcd_send_nibble(n >> 4); // first Hi nibble
lcd_send_nibble(n & 0xf); // then LOW nibble
delay_ms(1); // 60 us is enough
}

/**********************************
init LCD
*********************************/
void lcd_init(void)
{
unsigned int8 i;

RS=0;
ENABLE =0;
delay_ms(20);
for(i=0 ;i < 3; i++)
{
lcd_send_nibble(0x03);
delay_ms(10);
}
lcd_send_nibble(0x02);
for(i=0; i < sizeof(LCD_INIT_STRING); i++)
{
lcd_send_byte(CMD, LCD_INIT_STRING[i]);
delay_ms(10);
}
}
void row1( void) { // go row 1
lcd_send_byte(CMD, LCD_ROW1);
}

void row2( void) {// go to row2
lcd_send_byte(CMD, LCD_ROW2);
}
void clear_lcd(void) {
lcd_send_byte(CMD,1); // clear LCD
}

/*================
Display
==============*/
void printlcd1( void) {
unsigned int8 i=0;
char c;
row1();

for ( i=0; i<strlen(LCDBuffer); i++) {
c=LCDBuffer[i];
lcd_send_byte(DATA,c);
}
}

void printLcd2( void) {
unsigned int8 i,c;
row2();
for ( i=0; i<strlen(LCDBuffer); i++) {
c=LCDBuffer[i];
lcd_send_byte(DATA,c);
}

}
void lcddelayTxtRow2 ( void) {

sprintf(LCDbuffer, "Delay %ds " , delay);
printLcd2();// disply the rwault 2. row
}

// init Hardware
void initHardware ( void)
{
setup_oscillator(OSC_8MHZ);
setup_comparator( NC_NC_NC_NC);
setup_spi(FALSE); // THis must be before TRIS command !!
port_b_pullups(TRUE); // INTCON2.7 =0
set_tris_b(0b11000000);
set_tris_c(0b00001111);

SSPEN =0;

}

/*********************************


**********************************/
void main(void)
{

delay_ms(100);
initHardware ();


lcd_init(); // THE VEEY IMPORTANT FUCTION
printf("\rLCD init end");

while(1)
{
sprintf( LCDBuffer,"Hello World");
printlcd1();
delay_ms(500);
printf("\rProgram start ");


}


} [/code]
I have tried to load CCS LCD program, but it is very complicated.
Can you help me how to modify this program to 18F2620 and 4 bit data in port B.
RB4 - PIN_B0, RB5-PIN_B1, RB6 -PIN_B2, RB7-PIN B3, RS -PIN_B4 and Enable PIN_C5. WR pin is not used.

Pekka
Ttelmah



Joined: 11 Mar 2010
Posts: 19326

View user's profile Send private message

PostPosted: Mon May 06, 2024 1:42 am     Reply with quote

As you have been told twice, use PCM_Programmers LCD driver (from the
code library here). This is much more flexible than the standard driver,
and is one of the really reliable bits of code, that makes life easier for
everyone.
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon May 06, 2024 3:25 am     Reply with quote

I have used PCM programmers LCD driver on numerous 16/18/24 and DsPICs
with no issues. Much easier than the CCS LCD driver and highly recommended.
_________________
Google and Forum Search are some of your best tools!!!!
pekka1234



Joined: 28 May 2017
Posts: 80

View user's profile Send private message

PostPosted: Mon May 06, 2024 5:49 am     Reply with quote

OK
I found flex_lcd.c in here.
I modified it and tried with my LCD driver.

It worked !
The display was not clear, but there was some charters.
And two rows!

Then I tried it second and more times, but not more working?

Pekka

Code:

// flex_lcd.c
// 6.5.2024
 

#include <18F2620.H>
#FUSES INTRC_IO
#device ADC=10
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT                //Code not protected from reading
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES PUT                      //Power Up Timer
#FUSES NOCPD                    //No EE protection
#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 FCMEN                    //Fail-safe clock monitor enabled
#FUSES NOMCLR                   //Master Clear pin not enabled
#FUSES NOWRT
#use delay(internal = 8000000)
#use rs232(baud=9600, parity=N,  xmit=PIN_C6, rcv=PIN_C7,errors, bits=8)  // RS232 asetukset
void lcd_init();
 void lcd_putc(string ); 
//==========================
void main()
{
delay_ms(1000);
printf("\rstart");
lcd_init();  // Always call this first.
printf("\rinit done");
lcd_putc("\fHello World\n");
lcd_putc("Line Number 2");
printf("\rAll done");

while(1);
}
// These pins are for the Microchip PicDem2-Plus board,
// which is what I used to test the driver.  Change these
// pins to fit your own board.

#define LCD_DB4   PIN_B3
#define LCD_DB5   PIN_B2
#define LCD_DB6   PIN_B1
#define LCD_DB7   PIN_B0

#define LCD_E     PIN_C5
#define LCD_RS    PIN_B4
#define LCD_RW    PIN_C4

// If you only want a 6-pin interface to your LCD, then
// connect the R/W pin on the LCD to ground, and comment
// out the following line.

#define USE_LCD_RW   0     

//========================================

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


int8 const LCD_INIT_STRING[4] =
{
 0x20 | (lcd_type << 2), // Func set: 4-bit, 2 lines, 5x8 dots
 0xc,                    // Display on
 1,                      // Clear display
 6                       // Increment cursor
 };
                             

//-------------------------------------
void lcd_send_nibble(int8 nibble)
{
// Note:  !! converts an integer expression
// to a boolean (1 or 0).
 output_bit(LCD_DB4, !!(nibble & 1));
 output_bit(LCD_DB5, !!(nibble & 2));
 output_bit(LCD_DB6, !!(nibble & 4));   
 output_bit(LCD_DB7, !!(nibble & 8));   

 delay_cycles(1);
 output_high(LCD_E);
 delay_us(2);
 output_low(LCD_E);
}

//-----------------------------------
// This sub-routine is only called by lcd_read_byte().
// It's not a stand-alone routine.  For example, the
// R/W signal is set high by lcd_read_byte() before
// this routine is called.     

#ifdef USE_LCD_RW
int8 lcd_read_nibble(void)
{
int8 retval;
// Create bit variables so that we can easily set
// individual bits in the retval variable.
#bit retval_0 = retval.0
#bit retval_1 = retval.1
#bit retval_2 = retval.2
#bit retval_3 = retval.3

retval = 0;
   
output_high(LCD_E);
delay_cycles(1);

retval_0 = input(LCD_DB4);
retval_1 = input(LCD_DB5);
retval_2 = input(LCD_DB6);
retval_3 = input(LCD_DB7);
 
output_low(LCD_E);
   
return(retval);   
}   
#endif

//---------------------------------------
// Read a byte from the LCD and return it.

#ifdef USE_LCD_RW
int8 lcd_read_byte(void)
{
int8 low;
int8 high;

output_high(LCD_RW);
delay_cycles(1);

high = lcd_read_nibble();

low = lcd_read_nibble();

return( (high<<4) | low);
}
#endif

//----------------------------------------
// Send a byte to the LCD.
void lcd_send_byte(int8 address, int8 n)
{
output_low(LCD_RS);
 
 
delay_us(60);
 
 
if(address)
   output_high(LCD_RS);
else
   output_low(LCD_RS);
 
 delay_cycles(1);

 
delay_cycles(1);
 
 
output_low(LCD_E);

lcd_send_nibble(n >> 4);
lcd_send_nibble(n & 0xf);
 
}

//----------------------------
void lcd_init(void)
{
int8 i;

output_low(LCD_RS);

printf("\rlow lcd_E\r");
output_low(LCD_E);

delay_ms(15);

for(i=0 ;i < 3; i++)
   {
    lcd_send_nibble(0x03);
    delay_ms(5);
    printf("%x send 3\r",i);
   // getch();
   }
  printf("send2\r");
lcd_send_nibble(0x02);
 //  getch();
for(i=0; i < sizeof(LCD_INIT_STRING); i++)
   {
     
    lcd_send_byte(0, LCD_INIT_STRING[i]);
     printf("lcd_send_byte %x\r",LCD_INIT_STRING[i]);
    // If the R/W signal is not used, then
    // the busy bit can't be polled.  One of
    // the init commands takes longer than
    // the hard-coded delay of 60 us, so in
    // that case, lets just do a 5 ms delay
    // after all four of them.
    //getch();
    delay_ms(10);
   }

}

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

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

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

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

//-----------------------------
void lcd_putc(char c)
{
 switch(c)
   {
    case '\f':
      lcd_send_byte(0,1);
      delay_ms(2);
      break;
   
    case '\n':
       lcd_gotoxy(1,2);
       break;
   
    case '\b':
       lcd_send_byte(0,0x10);
       break;
   
    default:
       lcd_send_byte(1,c);
       break;
   }
}
pekka1234



Joined: 28 May 2017
Posts: 80

View user's profile Send private message

PostPosted: Mon May 06, 2024 12:55 pm     Reply with quote

LCD problem solved!

I got today LCD working.
It was Enable bit was open.

I had not operating PIN_C4 and I changed it to PIN_C5,
but it was under trimmer potentio meter and it was difficult to put in operation.

Anyway I am very thankful all who tried to help me.

I will return to my original program.
Here is my working LCD
http://probyte.fi/LCDDISPLAY.jpg

Pekka Finland
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