dvlee
Newbie level 3
Hi,
Got this program I've been working on for some time now to get a VFD (vacuum fluorescent display) to show the messages inputted by a computer or sensor readings. I'm having difficulty getting it to compile. I've altered it so many times, it's becoming a bit frustrating. Can someone help me out here? The last build, using MPLABV8.84, seems to suggest definition inconsistencies with the macros in the header files, but on checking, the formatting appears correct still the error messages. I'm also thinking equivalence in terms of an LCD and also in terms of the connections to this VFD which has a 14-pin connection.
Here's what I got. Thanks.
//3.4-LCD 04-tue17-12
// The following program requires the pic18f458 MCU to send to a noritake Vacuum Fluorescent Display (model:CU20045-UW5A)
// the basic "Hello World" character string.
#pragma config OSC = HS, OSCS = ON
#pragma config BORV = 45, PWRT = ON, BOR = ON
#pragma config WDT = ON
#pragma config DEBUG = ON, LVP = ON, STVR = ON
#include<p18f458.h>
#define TRISD // Output for PortD.
#define LATD
#define TRISBbits.TRISB0 // Output for pins B0-2, pin D7.
#define LATBbits.LATB0
#define TRISBbits.TRISB1
#define LATBbits.LATB1
#define TRISBbits.TRISB2
#define LATBbits.LATB2
#define TRISDbits.TRISD7
#define LATDbits.LATD7
#define LCD_data PORTD
#define LCD_rs PORTBbits.RB0
#define LCD_rw PORTBbits.RB1
#define LCD_en PORTBbits.RB2
#define LCD_D7 PORTDbits.RD7
void ms40();
void LCD_busy();
void LCD_init();
void LCD_senddata(unsigned char var);
void LCD_command(unsigned char var);
void LCD_sendstring(unsigned char *var);
void ms40()
{
int i;
for(i=0;i<9000;i++);
}
void LCD_busy()
{
LCD_D7 = 1; //Make D7th bit of LCD as i/p
LCD_en = 1; //Make port pin as o/p
LCD_rs = 0; //Selected command register
LCD_rw = 1; //We are reading
while(LCD_D7) //read busy flag again and again till it becomes 0
{
LCD_en = 0; //Enable H->L
LCD_en = 1;
}
}
void LCD_init()
{
LCD_data = 0x38; //Function set: 2 Line, 8-bit, 5x7 dots
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command
LCD_data = 0x0F; //Display on, Curson blinking command
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command
LCD_data = 0x01; //Clear LCD
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command
LCD_data = 0x06; //Entry mode, auto increment with no shift
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy();
}
void LCD_senddata(unsigned char var)
{
LCD_data = a; //Function set: 2 Line, 8-bit, 5x7 dots
LCD_rs = 1; //Selected data register
LCD_rw = 0; //We are writing
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command
}
void LCD_command(unsigned char var)
{
LCD_data = var; //Function set: 2 Line, 8-bit, 5x7 dots
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in instruction register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command
}
void LCD_sendstring(unsigned char *var)
{
while(*var) //till string ends
LCD_senddata(*var++); //send characters one by one
}
void main()
{
TRISD = 0b00000000;//PORT D, RB0-2, RD7 for output.
LATD = 1;
TRISBbits.TRISB0 = 0;
LATBbits.LATB0 = 1;
TRISBbits.TRISB1 = 0;
LATBbits.LATB1 = 1;
TRISBbits.TRISB2 = 0;
LATBbits.LATB2 = 1;
TRISDbits.TRISD7 = 0;
LATDbits.LATD7 = 1;
ms40();
LCD_init();
LCD_command(0x83);
LCD_sendstring('HELLO WORLD');
}
Got this program I've been working on for some time now to get a VFD (vacuum fluorescent display) to show the messages inputted by a computer or sensor readings. I'm having difficulty getting it to compile. I've altered it so many times, it's becoming a bit frustrating. Can someone help me out here? The last build, using MPLABV8.84, seems to suggest definition inconsistencies with the macros in the header files, but on checking, the formatting appears correct still the error messages. I'm also thinking equivalence in terms of an LCD and also in terms of the connections to this VFD which has a 14-pin connection.
Here's what I got. Thanks.
//3.4-LCD 04-tue17-12
// The following program requires the pic18f458 MCU to send to a noritake Vacuum Fluorescent Display (model:CU20045-UW5A)
// the basic "Hello World" character string.
#pragma config OSC = HS, OSCS = ON
#pragma config BORV = 45, PWRT = ON, BOR = ON
#pragma config WDT = ON
#pragma config DEBUG = ON, LVP = ON, STVR = ON
#include<p18f458.h>
#define TRISD // Output for PortD.
#define LATD
#define TRISBbits.TRISB0 // Output for pins B0-2, pin D7.
#define LATBbits.LATB0
#define TRISBbits.TRISB1
#define LATBbits.LATB1
#define TRISBbits.TRISB2
#define LATBbits.LATB2
#define TRISDbits.TRISD7
#define LATDbits.LATD7
#define LCD_data PORTD
#define LCD_rs PORTBbits.RB0
#define LCD_rw PORTBbits.RB1
#define LCD_en PORTBbits.RB2
#define LCD_D7 PORTDbits.RD7
void ms40();
void LCD_busy();
void LCD_init();
void LCD_senddata(unsigned char var);
void LCD_command(unsigned char var);
void LCD_sendstring(unsigned char *var);
void ms40()
{
int i;
for(i=0;i<9000;i++);
}
void LCD_busy()
{
LCD_D7 = 1; //Make D7th bit of LCD as i/p
LCD_en = 1; //Make port pin as o/p
LCD_rs = 0; //Selected command register
LCD_rw = 1; //We are reading
while(LCD_D7) //read busy flag again and again till it becomes 0
{
LCD_en = 0; //Enable H->L
LCD_en = 1;
}
}
void LCD_init()
{
LCD_data = 0x38; //Function set: 2 Line, 8-bit, 5x7 dots
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command
LCD_data = 0x0F; //Display on, Curson blinking command
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command
LCD_data = 0x01; //Clear LCD
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command
LCD_data = 0x06; //Entry mode, auto increment with no shift
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy();
}
void LCD_senddata(unsigned char var)
{
LCD_data = a; //Function set: 2 Line, 8-bit, 5x7 dots
LCD_rs = 1; //Selected data register
LCD_rw = 0; //We are writing
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command
}
void LCD_command(unsigned char var)
{
LCD_data = var; //Function set: 2 Line, 8-bit, 5x7 dots
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in instruction register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command
}
void LCD_sendstring(unsigned char *var)
{
while(*var) //till string ends
LCD_senddata(*var++); //send characters one by one
}
void main()
{
TRISD = 0b00000000;//PORT D, RB0-2, RD7 for output.
LATD = 1;
TRISBbits.TRISB0 = 0;
LATBbits.LATB0 = 1;
TRISBbits.TRISB1 = 0;
LATBbits.LATB1 = 1;
TRISBbits.TRISB2 = 0;
LATBbits.LATB2 = 1;
TRISDbits.TRISD7 = 0;
LATDbits.LATD7 = 1;
ms40();
LCD_init();
LCD_command(0x83);
LCD_sendstring('HELLO WORLD');
}