handsprince
Member level 2
i had wrote a lcd display code as below using c18; but it is not function, can anyone check for me:
code:
#include <stdio.h>
#include <p18f4620.h>
#include <xlcd.h>
#include <delays.h>
void DelayFor18TCY( void )
{
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
}
void DelayPORXLCD (void)
{
Delay1KTCYx(60); // Delay of 15ms
// Cycles = (TimeDelay * Fosc) / 4
// Cycles = (15ms * 16MHz) / 4
// Cycles = 60,000
return;
}
void DelayXLCD (void)
{
Delay1KTCYx(20); // Delay of 5ms
// Cycles = (TimeDelay * Fosc) / 4
// Cycles = (5ms * 16MHz) / 4
// Cycles = 20,000
return;
}
void main()
{
TRISB = 0x00;
OpenXLCD(FOUR_BIT & LINES_5X7);
while(1)
{
putrsXLCD( "Hello World" );
}
}
*******************************************************
XLCD.h haeder file i modified
#define UPPER
/* DATA_PORT defines the port to which the LCD data lines are connected */
#define DATA_PORT PORTB
#define TRIS_DATA_PORT TRISB
/* CTRL_PORT defines the port where the control lines are connected.
* These are just samples, change to match your application.
*/
#define RW_PIN PORTBbits.RB1 /* PORT for RW */
#define TRIS_RW DDRBbits.RB1 /* TRIS for RW */
#define RS_PIN PORTBbits.RB2 /* PORT for RS */
#define TRIS_RS DDRBbits.RB2 /* TRIS for RS */
#define E_PIN PORTBbits.RB3 /* PORT for E */
#define TRIS_E DDRBbits.RB3 /* TRIS for E */
code:
#include <stdio.h>
#include <p18f4620.h>
#include <xlcd.h>
#include <delays.h>
void DelayFor18TCY( void )
{
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
}
void DelayPORXLCD (void)
{
Delay1KTCYx(60); // Delay of 15ms
// Cycles = (TimeDelay * Fosc) / 4
// Cycles = (15ms * 16MHz) / 4
// Cycles = 60,000
return;
}
void DelayXLCD (void)
{
Delay1KTCYx(20); // Delay of 5ms
// Cycles = (TimeDelay * Fosc) / 4
// Cycles = (5ms * 16MHz) / 4
// Cycles = 20,000
return;
}
void main()
{
TRISB = 0x00;
OpenXLCD(FOUR_BIT & LINES_5X7);
while(1)
{
putrsXLCD( "Hello World" );
}
}
*******************************************************
XLCD.h haeder file i modified
#define UPPER
/* DATA_PORT defines the port to which the LCD data lines are connected */
#define DATA_PORT PORTB
#define TRIS_DATA_PORT TRISB
/* CTRL_PORT defines the port where the control lines are connected.
* These are just samples, change to match your application.
*/
#define RW_PIN PORTBbits.RB1 /* PORT for RW */
#define TRIS_RW DDRBbits.RB1 /* TRIS for RW */
#define RS_PIN PORTBbits.RB2 /* PORT for RS */
#define TRIS_RS DDRBbits.RB2 /* TRIS for RS */
#define E_PIN PORTBbits.RB3 /* PORT for E */
#define TRIS_E DDRBbits.RB3 /* TRIS for E */