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

PIC18F2520 LCD portB

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



Joined: 12 Apr 2015
Posts: 3
Location: Estonia

View user's profile Send private message

PIC18F2520 LCD portB
PostPosted: Mon Apr 13, 2015 2:20 pm     Reply with quote

Hello
Imagine an engineering student, who can't run lcd. I've going nuts here.
I'm using PIC18F2520 with two different hd44780 LCD devices (ill attach pictures). Basically I've spent many days on that problem and i have no result. My best outcome was some gibberish on 420 lcd. I've tried MPlab, MikroC without success (mplab-complicated). I've tried (output_high/low) all the b pins. they work fine, port a relay clicks. Tried all the CCS drivers.

Good CCS ppl please help me to solve this problem. I've seen this PIC driving LCD from b pins. True-it had code from mplab. Is it possible that there is something wrong with my compiler?

https://www.imageupload.co.uk/image/ZEGe
https://www.imageupload.co.uk/image/ZEGr
https://www.imageupload.co.uk/image/ZEGP
https://www.imageupload.co.uk/image/ZEGJ
https://www.imageupload.co.uk/image/ZEGM
https://www.imageupload.co.uk/image/ZEGQ
https://www.imageupload.co.uk/image/ZEGd

from ccs
Code:
#include <18F2520.h>
#FUSES NOWDT, NOPROTECT, NOBROWNOUT,NOPUT,NOLVP,NOPBADEN, NOXINST
#use delay(clock=8000000)

#include <flex_lcd.c>
//!#define LCD_ENABLE_PIN  PIN_B0                                    ////
//!#define LCD_RS_PIN      PIN_B1                                    ////
//!//#define LCD_RW_PIN      PIN_E2                                  ////
//!#define LCD_DATA4       PIN_B4                                    ////
//!#define LCD_DATA5       PIN_B5                                    ////
//!#define LCD_DATA6       PIN_B6                                    ////
//!#define LCD_DATA7       PIN_B7     
////
void main()
{
   SET_TRIS_B(0);
   setup_adc(ADC_OFF);
   setup_adc(NO_ANALOGS);
   SETUP_CCP1(CCP_OFF);
   setup_spi(FALSE);
   setup_counters(T0_INTERNAL,WDT_16MS);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
delay_ms(50);
lcd_init();
delay_ms(50);
 while(1)
     {
      delay_ms(500);
      output_high(PIN_A5);
      delay_ms(500);
      output_low(PIN_A5);
      // Clear the LCD.
      printf(lcd_putc, "\f");
      lcd_putc("\f");
      lcd_putc("\fHello World\n");
      lcd_putc("Line Number 2");
      delay_ms(500);
      lcd_putc("\f");
      printf(lcd_putc, "ABCDEFGHIJKLMNO");
      printf(lcd_putc, "\n PIC 18f2520");
      delay_ms(500);
     }
}

snippet from flex_lcd driver
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_B0
#define LCD_RS    PIN_B1
//#define LCD_RW    PIN_A1

// 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   1     
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 13, 2015 3:25 pm     Reply with quote

Can you post the manufacturer and part number of your LCD ?

Your photos show a bunch of colored wires, but it's hard to tell where
they go. Can you post a schematic or a list of the connections to the
LCD, and between the LCD and the PIC.
temtronic



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

View user's profile Send private message

PostPosted: Mon Apr 13, 2015 4:19 pm     Reply with quote

One comment about the wiring. It's 'better' if you can use a wire with the colour of the pin number, if possible. Red for pin 2 or 12, grn for 5 or 15, etc.
Also ... try to solder only one wire, ONCE to any LCD module. they tend to use super thin copper traces and just a little too much heat will destroy the trace, giving you all sorts of grief.
I usually solder a tall 'header' to LCDs as it allows it to be inserted into a 'white breadboard' for quick testing.It also will 'raise' the LCD off the PIC board when it plugs into a mating header.

The flex driver is a known working driver..
hmm..
your delay_ms(50) just before the lcd_init() should be changed to delay_ms(500), to give a 1/2 second delay before the PIC accesses the LCD. While 1/2 second may seem too much, I've never had 'issues' with any LCD for the past 15-20 years.



Just some info....

Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 13, 2015 4:31 pm     Reply with quote

Quote:

#include <18F2520.h>
#FUSES NOWDT, NOPROTECT, NOBROWNOUT,NOPUT,NOLVP,NOPBADEN, NOXINST
#use delay(clock=8000000)

Reviewing your code, I noticed that you have no oscillator fuse.
I suggest that you add the internal oscillator fuse, as shown
below in bold:
Quote:

#include <18F2520.h>
#FUSES INTRC_IO, NOWDT, NOPROTECT, NOBROWNOUT,NOPUT,NOLVP,NOPBADEN, NOXINST
#use delay(clock=8000000)

It's essential to have an oscillator fuse.
ic4ru5



Joined: 12 Apr 2015
Posts: 3
Location: Estonia

View user's profile Send private message

PostPosted: Tue Apr 14, 2015 3:59 am     Reply with quote

I've tried to add INTRC_IO. Also I've tried to add time-delay before and after init function. No result.
Ill reinstall CCS and reassemble schematic on breadboard, when i get time, for more testing.Thanks for help so far.
Here are some docs that I've made for this project.
http://www.docdroid.net/xcq3/codebreaker-bb2.pdf.html
http://www.docdroid.net/xcq4/codebreaker-schem2.pdf.html
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Tue Apr 14, 2015 9:00 am     Reply with quote

Also there is no high frequency decoupling on the board anywhere.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 14, 2015 3:20 pm     Reply with quote

Questions remain:

Quote:
I've tried to add INTRC_IO

1. Did you then remove it after it apparently had no effect ?
Strangely, sometimes people do this. You MUST have an oscillator fuse.
If you took out the INTRC_IO fuse, please put it back in.

2. Have you ever done a blinking LED program on this board ?
This will prove that the PIC is working in a basic way.

3. Which flex driver are you using ? Your LCD is a 20x4 lcd.
There are different flex drivers for 16x2 and 20x4 lcds.
You must use the correct driver for your LCD.

4. According to the lcd data sheet, on page 6, it says Vdd is 3.3 volts:
http://www.tme.eu/en/Document/fc253875998eb2b0f049dcc7fdc9a0af/RC2004A-GHW-CSV.pdf
This is for the RC2004A-GHW-CSV lcd.
But you are running it at +5.0 volts, and the PIC is running at +5v.
This is not good.

5. What is the voltage on the contrast pin of the LCD ? It is set by
the trimpot and should be about -1.2v volt for a 3.3v lcd.
This point doesn't matter too much if the lcd has been damaged by
running it at 5v, and giving it 5v logic signals from the PIC.

You have another LCD with a different part number, I believe.
Post the manufacturer and part number of your 2nd lcd.
Maybe it's a 5v lcd.
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