I am using the PIC 16F877A to control the GLC24064 V2.0 and I am able to write to the LCD with the following program but the command to clear the screen and place the cursor does not work. The program is below and produces the following on the LCD;
feXfeHABCDEFGHIJKLMNOPQRSTUVWXYZ
and will wrap itself if placed again and again until the display scrolls upward.
Any assistance provided would be greatly appreciated.
#include <16F877A.h>
#device ICD=TRUE
#use delay (clock=10000000)
#use rs232(baud=19200, xmit=PIN_C6, rcv = PIN_C7)
void main() {
int j;
delay_ms(500);
printf("%xX",0xFE); // Clear screen
printf("%xH",0xFE); // Home position
for(j='A'; j<='Z'; j++)
{printf("%c",j);}
while(1);
}
Place cursor and clear screen using RS-232
-
- LCD?
- Posts: 3
- Joined: Mon Nov 08, 2010 10:14 am
-
- LCD?
- Posts: 3
- Joined: Mon Nov 08, 2010 10:14 am
Hi,
Thank you for trying things out.
You need to make sure that when you send the command 0xFE 0x58 (clear screen command) that you are sending only 2 bytes, and not a total of 4 bytes as you see in your display: 'fe58' which is 4 bytes.
Please check the printf format details of your compiler.
Or, give this a try:
printf("%x",254);
printf("%x",88 );
Let me know how it turns out.
Thank you for trying things out.
You need to make sure that when you send the command 0xFE 0x58 (clear screen command) that you are sending only 2 bytes, and not a total of 4 bytes as you see in your display: 'fe58' which is 4 bytes.
Please check the printf format details of your compiler.
Or, give this a try:
printf("%x",254);
printf("%x",88 );
Let me know how it turns out.
Raquel Malinis
Design and Development
Matrix Orbital
Design and Development
Matrix Orbital
-
- LCD?
- Posts: 3
- Joined: Mon Nov 08, 2010 10:14 am
The code that I needed for the CCS compiler was;
//clear screen
printf("%c",254);
printf("%c",88 );
As I understand it, the %c sends the raw code.
Also if you want to place the cursor;
//place cursor
printf("%c",254);
printf("%c",71);
printf("%c",3);
printf("%c",3);
This would place the cursor at position 3,3.
Below is the code I used if anyone needs it in the future
#include <16F877A.h>
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT,PUT
#use delay (clock=10000000)
#use rs232(baud=19200, xmit=PIN_C6, rcv = PIN_C7)
//clear screen
printf("%c",254);
printf("%c",88 );
As I understand it, the %c sends the raw code.
Also if you want to place the cursor;
//place cursor
printf("%c",254);
printf("%c",71);
printf("%c",3);
printf("%c",3);
This would place the cursor at position 3,3.
Below is the code I used if anyone needs it in the future
#include <16F877A.h>
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT,PUT
#use delay (clock=10000000)
#use rs232(baud=19200, xmit=PIN_C6, rcv = PIN_C7)
Code: Select all
void main()
{
int j;
int x;
x=0;
//clear screen
delay_ms (300);
printf("%c",254);
printf("%c",88 );
//place cursor
printf("%c",254);
printf("%c",71);
printf("%c",3); //place cursor at 3rd column over
printf("%c",5); //place cursor at 5th row down
for(j='A'; j<='Z'; j++)
{
printf("%c",j);
//delay_ms(10);
}
}