Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problems with PIC18F4620 and LCD

Status
Not open for further replies.

mariale442

Newbie level 2
Joined
Jul 28, 2006
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,324
pic18f4620 lcd

I'm migrating my PIC18F452 code to a PIC18F4620 and I'm stuck with the LCD code. What was working fine in the 452 now is not in the 4620.
Does anybody encountered with this sort of problems.

It is prety much important for me to make this thing work so any kind of help would be appreciated.

Thank you all. :cry::cry::cry:

Added after 16 minutes:

This is my code.

I don't know which is the problem :cry::cry::cry:

-----------------------------------------------------------------------------------------------
this is the source file:
-----------------------------------------------------------------------------------------------

#include "lcdconfig.h"
#include <p18f4620.h>

VOID lcd_wait ();
VOID lcd_init ();
VOID wrcmd (CHAR);

VOID pause(INT num)
// Utility routine to pause for
// a period of time.
{ while(num--)
{/*do nothing */
}
}

VOID lcd_init()
// Initialise the LCD Display.
{ PORTA = TRISA = 0;
TRISB = PORTB = 0xFF;
ADCON1 = 7;
wrcmd(0x30); // 8-bit mode - 1 line.
wrcmd(LCD_SETVISIBLE+0x04); // Display only - no cursors.
wrcmd(LCD_SETMODE+0x02); // Automatic Increment - Display shift left.
wrcmd(LCD_SETDDADDR+0x0F); // Initial Position far right.
}

VOID clearscreen ()
// Clear the LCD Screen and reset
// initial position.
{ wrcmd(LCD_CLS);
wrcmd(LCD_SETDDADDR+0x00);
}

/***** Utility Functions *****/

// Write a command to the LCD display.
VOID wrcmd (CHAR cmdcode)
{ TRISB = 0;
PORTB = cmdcode;

// Write to PORTB to latch data into the display.
// Toggle Pin 'E' to send the command.
PORTA = LCD_CMD_WR;
PORTA |= E_PIN_MASK;

Nop();
PORTA &= ~E_PIN_MASK;

lcd_wait();
}

VOID wrdata (CHAR data)
// Write a Character to the LCD Display.
{ TRISB = 0;
PORTB = data;

PORTA = LCD_DATA_WR;
PORTA |= E_PIN_MASK;

Nop();

PORTA &= ~E_PIN_MASK;

lcd_wait();
}

// Wait for the LCD busy flag to clear.
VOID lcd_wait ()
{ BYTE status;
TRISB = 0xFF;

PORTA = LCD_BUSY_RD;
do
{ PORTA |= E_PIN_MASK;

Nop();

status = PORTB;
PORTA &= ~E_PIN_MASK;
} while (status & 0x80);
}

CHAR buf [16]="1. Consultar ";

// Initialise our variables and call the
// Assembly routine to initialise the LCD display.

VOID calc_display (CHAR buf[16])
// Use the Output and Clearscreen routines from the
// *LCD_Write* assembly file to output ASCII values to the LCD.
{ INT8 i;
clearscreen();
for (i=0 ; i<strlen(buf); i++)
// { if (buf[calc_testkey(buf) || buf == 0x2D)
{
wrdata(buf);
pause(5000);
}
// }
}


VOID main (VOID)
{ lcd_init();
calc_display(buf);
}


-----------------------------------------------------------------------------------------------
this is the header file:
-----------------------------------------------------------------------------------------------

typedef void VOID;
typedef int INT;
typedef signed char INT8;
typedef signed int INT16;
typedef signed long INT32;
typedef unsigned short WORD;
typedef char CHAR;
typedef unsigned char BYTE;
typedef double FLOAT;
typedef long LONG;
typedef INT8 BOOL;

//LCD Config

#define MAX_DISPLAY_CHAR 16


//LCD Registers addresses (PORT B)
#define LCD_CMD_WR 0x00
#define LCD_DATA_WR 0x01
#define LCD_BUSY_RD 0x02
#define LCD_DATA_RD 0x03

//LCD Commands
#define LCD_CLS 0x01
#define LCD_HOME 0x02
#define LCD_SETMODE 0x04
#define LCD_SETVISIBLE 0x08
#define LCD_SHIFT 0x10
#define LCD_SETFUNCTION 0x20
#define LCD_SETCGADDR 0x40
#define LCD_SETDDADDR 0x80

#define E_PIN_MASK 0x04

#define FALSE 0
#define TRUE 1

--------------------------------------------------------------------------------------------
help meeeeeee... :cry::cry::cry:
 

16 2 lcd pic18f4620

Hi mariale442

I was wondering why you are not migrating to the recommended 18F4520 which is virtually the same chip - perhaps you require larger flash of the 4620?

Migration to the 4620 requires a little more care.

Check ADCON0 and ADCON1 - they are not indentical on the 452 & 4620
I think your problem may be in the LCD initalisation area. - I have not checked in detail.

... Polymath
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top