CF635 Send clear command to LCD in mikroC


New member
Hi. I wanna send clear LCD command to LCD in mikroC.
Should the code looke like:

UART1_Init(19200); // Initialize UART module at 115200 bps
Delay_ms(2000); // Wait for UART module to stabilize

I did connect LCD to PC and test it with Wintest and it works fine.
I have also check TX and RX with osciloscope if the command gets to the LCD and it does.
Even the presed keys transmit some code.
I dont know what am I doin wrong?
Any help would be appreciated.
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
USB LCD Displays - Graphic and Character LCDs with a Keypad

CF Kelsey

Staff member
To send a command you need to send a fully-formed packet as described in the datasheet. Wintest will also give you the bites needed to form the packet.

Here is a post with some additional resources:

From the datasheet:

All packets have the following structure:
<type> is one byte, and identifies the type and function of the packet:
TTcc cccc
|||| ||||--Command, response, error or report code 0-63
00 = normal command from host to CFA635
01 = normal response from CFA635 to host
10 = normal report from CFA635 to host (not in
direct response to a command from the host)
11 = error response from CFA635 to host (a packet
with valid structure but illegal content
was received by the CFA635)
<data_length> specifies the number of bytes that will follow in the data field.
The valid range of <data_length> is 0 to 22.
<data> is the payload of the packet. Each type of packet will have a specified <data_length> and format for <data> as well as algorithms for decoding data detailed below.
CRC is a standard 16-bit CRC of all the bytes in the packet except the CRC itself. The CRC is sent LSB first. At the port, the CRC immediately follows the last used element of data[ ]. See Appendix A: Demonstration Software and Sample Code for details.
The following C definition may be useful for understanding the packet structure.
typedef struct
unsigned char command;
unsigned char data_length;
unsigned char data[MAX_DATA_LENGTH];
unsigned short CRC;
Crystalfontz supplies a demonstration and test program, cfTest, that can be used to experiment with and test the CFA635’s operation. We also offer 635WinTest, which is a simpler, open-source program. Included in the 635WinTest source is a CRC algorithm and an algorithm that detects and reconciles packets. The algorithm will automatically re-synchronize to the next valid packet in the event of any communications errors. Please follow the algorithm in the sample code closely in order to realize the benefits of using the packet communications.


New member
uh on some other RS232 controlled LCD I only need'ed to do this under mikroC :
UART1_Write(0xfe); //command for LCD to receive command
UART1_Write(0x47); //command to SetLcdCursorPosition
UART1_Write(a); //coloum
UART1_Write(b); //row
UART1_Write_text("My text");

Whell thank you for your ansver. If I would live near you I would buy a beer for this expanation.
This will be my new challenge. :)


New member
Command Gets To The LCD

This command will allow you to control the display of the screen. It is useful if you want to change the background color of the screen. You can do this by using the following commands:

set_background_color(hex) - Sets the hex value of the color you wish to use as the background.

set_background_pattern(image) - Sets the image you wish to use as your background pattern.

set_background(image) - Sets an image as the background for the entire display.

set_text_color(hex) – Sets the hex value of text color you wish to use.

set_text(string) - Sets the string you wish to display on the screen.

set_font(font_name) - Sets the name of font you wish to use. There are many fonts included with the firmware.

set_font_size(number) - Sets the size of the font you wish to use

set_line_spacing(number) - Sets how much space between each line of text.

set_cursor(x, y) - Moves the cursor position to (x,y).

get_cursor() - Returns the current cursor position.

get_screen_width() - Returns the width of the screen.

get_screenheight() - Returns the height of the screen.