graphical lcd programming with flowcode v3

Any general or miscellaneous queries that do not fit into the other forum catagories

Moderators: Benj, Mods

Post Reply
Kumaran
Posts: 73
Joined: Tue Apr 08, 2008 5:23 pm
Been thanked: 1 time
Contact:

graphical lcd programming with flowcode v3

Post by Kumaran »

The program when executed gives some errors such as "missing paren, missing semicolon,etc.."
Pls tell the right program to interface monographic Lcd with IC18F4550
using flowcodev3



//================================
// Paste in the top of your 'GLCD - modified.C' file!
//================================
#define GLCD_DI PIN_C0 // Data or Instruction input
#define GLCD_RW PIN_C1 // Read/Write
#define GLCD_E PIN_C2 // Enable
#define GLCD_CS1 PIN_A3 // Chip Selection 1
#define GLCD_CS2 PIN_A4 // Chip Selection 2
#define GLCD_RST PIN_A5 // Reset

//================================
// Paste above "const int8 TEXT[51][5]"
//================================
//3x5 Font packed two per definition
//Original format from http://instruct1.cit.cornell.edu/course ... ideo32v2.c
// - Modified by Steven Cholewiak (http://www.semifluid.com)
// - 08/08/06 - Included punctuation characters
const int8 TEXT35[95][5]={
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //SPACE
0b01000100, 0b01000100, 0b01000100, 0b00000000, 0b01000100, //!
0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, //"
0b10101010, 0b11101110, 0b10101010, 0b11101110, 0b10101010, //#
0b01100110, 0b11001100, 0b11001100, 0b01100110, 0b11101110, //$
0b10101010, 0b00100010, 0b01000100, 0b10001000, 0b10101010, //%
0b01000100, 0b10101010, 0b01000100, 0b10101010, 0b01100110, //&
0b01000100, 0b01000100, 0b00000000, 0b00000000, 0b00000000, //'
0b01000100, 0b10001000, 0b10001000, 0b10001000, 0b01000100, //(
0b01000100, 0b00100010, 0b00100010, 0b00100010, 0b01000100, //)
0b00000000, 0b10101010, 0b01000100, 0b10101010, 0b00000000, //*
0b00000000, 0b01000100, 0b11101110, 0b01000100, 0b00000000, //+
0b00000000, 0b00000000, 0b00000000, 0b01000100, 0b10001000, //,
0b00000000, 0b00000000, 0b11101110, 0b00000000, 0b00000000, //-
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01000100, //.
0b00100010, 0b00100010, 0b01000100, 0b10001000, 0b10001000, ///
0b11101110, 0b10101010, 0b10101010, 0b10101010, 0b11101110, //0
0b01000100, 0b11001100, 0b01000100, 0b01000100, 0b11101110, //1
0b11101110, 0b00100010, 0b11101110, 0b10001000, 0b11101110, //2
0b11101110, 0b00100010, 0b11101110, 0b00100010, 0b11101110, //3
0b10101010, 0b10101010, 0b11101110, 0b00100010, 0b00100010, //4
0b11101110, 0b10001000, 0b11101110, 0b00100010, 0b11101110, //5
0b11001100, 0b10001000, 0b11101110, 0b10101010, 0b11101110, //6
0b11101110, 0b00100010, 0b01000100, 0b10001000, 0b10001000, //7
0b11101110, 0b10101010, 0b11101110, 0b10101010, 0b11101110, //8
0b11101110, 0b10101010, 0b11101110, 0b00100010, 0b01100110, //9
0b00000000, 0b01000100, 0b00000000, 0b01000100, 0b00000000, //:
0b00000000, 0b01000100, 0b00000000, 0b01000100, 0b10001000, //;
0b00100010, 0b01000100, 0b10001000, 0b01000100, 0b00100010, //<
0b00000000, 0b11101110, 0b00000000, 0b11101110, 0b00000000, //=
0b10001000, 0b01000100, 0b00100010, 0b01000100, 0b10001000, //>
0b11001100, 0b00100010, 0b01100110, 0b00000000, 0b01000100, //?
0b01000100, 0b10101010, 0b11101110, 0b10001000, 0b01100110, //@
0b11101110, 0b10101010, 0b11101110, 0b10101010, 0b10101010, //A
0b11001100, 0b10101010, 0b11101110, 0b10101010, 0b11001100, //B
0b11101110, 0b10001000, 0b10001000, 0b10001000, 0b11101110, //C
0b11001100, 0b10101010, 0b10101010, 0b10101010, 0b11001100, //D
0b11101110, 0b10001000, 0b11101110, 0b10001000, 0b11101110, //E
0b11101110, 0b10001000, 0b11101110, 0b10001000, 0b10001000, //F
0b11101110, 0b10001000, 0b10001000, 0b10101010, 0b11101110, //G
0b10101010, 0b10101010, 0b11101110, 0b10101010, 0b10101010, //H
0b11101110, 0b01000100, 0b01000100, 0b01000100, 0b11101110, //I
0b00100010, 0b00100010, 0b00100010, 0b10101010, 0b11101110, //J
0b10001000, 0b10101010, 0b11001100, 0b11001100, 0b10101010, //K
0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b11101110, //L
0b10101010, 0b11101110, 0b11101110, 0b10101010, 0b10101010, //M
0b00000000, 0b11001100, 0b10101010, 0b10101010, 0b10101010, //N
0b01000100, 0b10101010, 0b10101010, 0b10101010, 0b01000100, //O
0b11101110, 0b10101010, 0b11101110, 0b10001000, 0b10001000, //P
0b01000100, 0b10101010, 0b10101010, 0b11101110, 0b01100110, //Q
0b11101110, 0b10101010, 0b11001100, 0b11101110, 0b10101010, //R
0b11101110, 0b10001000, 0b11101110, 0b00100010, 0b11101110, //S
0b11101110, 0b01000100, 0b01000100, 0b01000100, 0b01000100, //T
0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b11101110, //U
0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b01000100, //V
0b10101010, 0b10101010, 0b11101110, 0b11101110, 0b10101010, //W
0b00000000, 0b10101010, 0b01000100, 0b01000100, 0b10101010, //X
0b10101010, 0b10101010, 0b01000100, 0b01000100, 0b01000100, //Y
0b11101110, 0b00100010, 0b01000100, 0b10001000, 0b11101110, //Z
0b11101110, 0b10001000, 0b10001000, 0b10001000, 0b11101110, //[
0b10001000, 0b10001000, 0b01000100, 0b00100010, 0b00100010, //\
0b11101110, 0b00100010, 0b00100010, 0b00100010, 0b11101110, //]
0b01000100, 0b10101010, 0b00000000, 0b00000000, 0b00000000, //^
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11101110, //_
0b10001000, 0b01000100, 0b00000000, 0b00000000, 0b00000000, //`
0b00000000, 0b01000100, 0b10101010, 0b10101010, 0b01100110, //a
0b10001000, 0b11001100, 0b10101010, 0b10101010, 0b11001100, //b
0b00000000, 0b01100110, 0b10001000, 0b10001000, 0b01100110, //c
0b00100010, 0b01100110, 0b10101010, 0b10101010, 0b01100110, //d
0b00000000, 0b01000100, 0b10101010, 0b11001100, 0b01100110, //e
0b01100110, 0b01000100, 0b11101110, 0b01000100, 0b01000100, //f
0b00000000, 0b01000100, 0b10101010, 0b01100110, 0b11001100, //g
0b10001000, 0b11001100, 0b10101010, 0b10101010, 0b10101010, //h
0b01000100, 0b00000000, 0b01000100, 0b01000100, 0b01000100, //i
0b01000100, 0b00000000, 0b01000100, 0b01000100, 0b10001000, //j
0b10001000, 0b10001000, 0b10101010, 0b11001100, 0b10101010, //k
0b01000100, 0b01000100, 0b01000100, 0b01000100, 0b01000100, //l
0b00000000, 0b11101110, 0b11101110, 0b10101010, 0b10101010, //m
0b00000000, 0b11001100, 0b10101010, 0b10101010, 0b10101010, //n
0b00000000, 0b01000100, 0b10101010, 0b10101010, 0b01000100, //o
0b00000000, 0b11001100, 0b10101010, 0b11001100, 0b10001000, //p
0b00000000, 0b01100110, 0b10101010, 0b01100110, 0b00100010, //q
0b00000000, 0b10001000, 0b11101110, 0b10001000, 0b10001000, //r
0b00000000, 0b01100110, 0b11001100, 0b00100010, 0b11001100, //s
0b01000100, 0b11101110, 0b01000100, 0b01000100, 0b01000100, //t
0b00000000, 0b10101010, 0b10101010, 0b10101010, 0b01000100, //u
0b00000000, 0b10101010, 0b10101010, 0b01000100, 0b01000100, //v
0b00000000, 0b10101010, 0b10101010, 0b11101110, 0b10101010, //w
0b00000000, 0b10101010, 0b01000100, 0b01000100, 0b10101010, //x
0b00000000, 0b10101010, 0b10101010, 0b01100110, 0b11001100, //y
0b00000000, 0b11101110, 0b01100110, 0b11001100, 0b11101110, //z
0b00100010, 0b01000100, 0b11001100, 0b01000100, 0b00100010, //{
0b01000100, 0b01000100, 0b01000100, 0b01000100, 0b01000100, //|
0b10001000, 0b01000100, 0b01100110, 0b01000100, 0b10001000, //}
0b00000000, 0b11001100, 0b10101010, 0b00000000, 0b00000000 //~
};

//================================
// Paste above "glcd_fillScreen(int1 color)"
//================================
// Purpose: Write small text on a graphic LCD
// Inputs: (x,y) - The upper left coordinate of the first letter
// textptr - A pointer to an array of text to display
// color - ON or OFF

//char characterSet[] = " !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
void glcd_text35(int8 x, int8 y, char* textptr, int1 color)
{
int i, j, k; // Loop counters
BYTE pixelData[5]; // Stores character data

for(i=0; textptr != '\0'; ++i, ++x) // Loop through the passed string
{
if((textptr >= ' ') && (textptr <= '~'))
memcpy(pixelData, TEXT35[textptr-' '], 5);
else
memcpy(pixelData, TEXT35[0], 5); // Default to space

if(x+3 >= GLCD_WIDTH) // Performs character wrapping
{
x = 0; // Set x at far left position
y += 5 + 1; // Set y at next position down
}
for(j=3; j>0; j--, x++) // Loop through character byte data
{
for(k=0; k<5; k++) // Loop through the vertical pixels
{
if(bit_test(pixelData[k], j)) // Check if the pixel should be set
{
glcd_pixel(x, y+k, color); // Draws the pixel
}
}
}
}
}

#include <18F2550.h>
#device ADC=8
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)

#build(reset=0x1, interrupt=0x8) // Necessary for Bootloader
#ORG 0x0F00,0x0FFF {} // Necessary for Bootloader

#use rs232(stream=PC, baud=115200, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#include <GLCD - modified.c> // Includes 3x5 font

#INT_RDA
void serial_isr() // Serial Interrupt
{
if (fgetc(PC) == 0x12 & fgetc(PC) == 0x34 & fgetc(PC) == 0x56 & fgetc(PC) == 0x78 & fgetc(PC) == 0x90) #asm reset #endasm
}

void main() {
char characterSet[] = " !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";

SETUP_ADC_PORTS(NO_ANALOGS); // Disable ADC
SETUP_ADC(ADC_OFF); // Disable ADC
SETUP_TIMER_0(RTCC_INTERNAL|RTCC_DIV_1); // Use the int. osc. for Timer 0
SETUP_TIMER_1(T1_DISABLED); // Disable Timer 1
SETUP_TIMER_2(T2_DISABLED, 127, 1); // Disable Timer 2
SETUP_TIMER_3(T3_DISABLED); // Disable Timer 3
SETUP_CCP1(CCP_OFF); // Disable CCP1
SETUP_CCP2(CCP_OFF); // Disable CCP2

enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);

glcd_init(ON); // Must initialize the LCD

glcd_text35(0, 0, characterSet, ON); // Write character set to LCD

while (TRUE) {}
}
I'''

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: graphical lcd programming with flowcode v3

Post by Benj »

Ok Please dont triple post when one topic will do !!!!!

There is an example for driving a KS0108 mono graphical LCD from Flowcode available from here.

http://www.matrixmultimedia.com/Flowcode_Components.php

Kumaran
Posts: 73
Joined: Tue Apr 08, 2008 5:23 pm
Been thanked: 1 time
Contact:

Re: graphical lcd programming with flowcode v3

Post by Kumaran »

i 've downloaded the program ,
but got some errors like /?(failed to generate expression...)
while executing the same ,how to implement the c code in custom component?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: graphical lcd programming with flowcode v3

Post by Benj »

Hello

All the instructions on how to do what you require are available on the top of the Beta Components page.

Kumaran
Posts: 73
Joined: Tue Apr 08, 2008 5:23 pm
Been thanked: 1 time
Contact:

Re: graphical lcd programming with flowcode v3

Post by Kumaran »

could u pls provide the conection details :
data port--?
enable--?
read/write--?
Thanks in advance

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: graphical lcd programming with flowcode v3

Post by Benj »

Hello

The connections are currently set to the following.

#define MX_DATA_PORT portd //%a
#define MX_DATA_TRIS trisd //%b
#define MX_CONTROL_PORT portc //%c
#define MX_CONTROL_TRIS trisc //%d
#define MX_CS1 0 //%e
#define MX_CS2 1 //%f
#define MX_DAT_INST 2 //%g
#define MX_ENABLE 3 //%h
#define MX_READ_WRITE 4 //%i

Eg the 8 data pins are connected to PortD and the remaining 5 control pins are connected to PortC.

This information is near the top of the custom C code file so you can change to suit your application.

Kumaran
Posts: 73
Joined: Tue Apr 08, 2008 5:23 pm
Been thanked: 1 time
Contact:

Re: graphical lcd programming with flowcode v3

Post by Kumaran »

i'm not getting the text displayed even after connecting all the ports n pins correctly
can u help me out :roll:

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: graphical lcd programming with flowcode v3

Post by Benj »

Hello

Have you copied the custom code file over the custom code C file in the components directory of Flowcode. You can check this by compiling to C in Flowcode and then seeing if the LCD functions are available.

If you are still having probems then please can you post your Flowcode project file and the C code file that is generated and I will have a look for you.

Kumaran
Posts: 73
Joined: Tue Apr 08, 2008 5:23 pm
Been thanked: 1 time
Contact:

Re: graphical lcd programming with flowcode v3

Post by Kumaran »

Hi

I have tried the example file that is came along with the download. Please see the project file and C Code generated. today I have recieved the flowcode V4, So I am posting the project created in Flowcode V4.

Thanks
M.S.Senthilkumaran
Attachments
LCD Print Test.c
(21.2 KiB) Downloaded 411 times
LCD Print Test.fcf
(5.5 KiB) Downloaded 447 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: graphical lcd programming with flowcode v3

Post by Benj »

Hello,

I've got one of these displays on my desk so Ill connect it up tomorrow and try out your program to see if I can spot the problem. Not sure if I have a 16F871 to test on but I should have one of the chips from that family.

Post Reply