CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Appreciate help with Serial LCD.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Arizona Chris



Joined: 20 Dec 2014
Posts: 69
Location: Arizona

View user's profile Send private message Visit poster's website

Appreciate help with Serial LCD.
PostPosted: Thu Jan 01, 2015 10:47 am     Reply with quote

Hello all,

We have finished the Embedded C programming book finally, and one last thing to try before ordering the full blown software is to try to get our Scott Edwards serial lcd to put out numbers and text. The display is set to run at 9600kb, 8N1 no parity. We have used this brand LCD for 12 years with PIC basic and have had no issues. I get just garbage on the display. Using the E3 board with the 18F14K50 chip. I've got a LED to flash every time a serial stream is sent, so I know the PIC is operating. An oscilloscope check on the data out pin shows clear serial data. Here is the code I have tried:

Code:
#include <e3.h>
#include <ios.h>
#use rs232(baud = 9600, xmit=PIN_B6, bits=8, parity=N, stream=SERIAL)



void main() {

while (true)  {

char c = 14;

fputc(c,SERIAL);

//SERIAL << "HELLO" << endl;

//printf(12,"hello");

output_toggle(PIN_C6);

delay_ms(500);

}
 
   
}
   


I have tried all three methods seen here, but get garbage. The LCD works perfect on our other projects programed with Pic basic.

What Am I missing here? I coudnt find anything specific on the forum search.

Chris
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Thu Jan 01, 2015 11:12 am     Reply with quote

Couple of things to check - you say "9600kb" - I assume you mean 9600 baud (sometimes the obvious is so obvious you overlook it). Check the serial data with the scope - are the bit times correct (not just a bit stream there). I have not used that LCD module, but many of the modules we work with have a setup / reset time and either ignore stuff sent to them before they have completed init or show garbage. Are you using TTL levels or RS-232 levels (what does the module require?). Remember that RS-232 is inverted data from the TTL level.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
Ttelmah



Joined: 11 Mar 2010
Posts: 19369

View user's profile Send private message

PostPosted: Thu Jan 01, 2015 11:28 am     Reply with quote

If you are talking about the Scott Edwards backpack units, these are designed to connect to _inverted_ serial data. They will connect directly to a PC serial port, _or_ to a processor sending inverted 5v serial. Change your RS232 setup to:

#use rs232(baud = 9600, xmit=PIN_B6, bits=8, parity=N, INVERT, stream=SERIAL)

As gpsmikey says pause a little before sending.
Arizona Chris



Joined: 20 Dec 2014
Posts: 69
Location: Arizona

View user's profile Send private message Visit poster's website

LCD serial
PostPosted: Thu Jan 01, 2015 1:38 pm     Reply with quote

We are making progress! I can communicate with the display now, it indeed wants inverted data. I was able to control the backlight, clear screen, and send either single or a string of characters to the screen perfectly using the code below. To send an integer, I finally ended up with fprintf and defined the output as the stream defined at the top and use %u just before the variable to get it to show up on the LCD.

Thank you for all your help, you guys are amazing.

Chris

Code:
#include <e3.h>
#use rs232(baud = 9600, xmit=PIN_B6, bits=8, parity=N, INVERT, stream=SERIAL)

void main() {

while (true)  {

char c = 'a';
int x = 255;

fputc(12,SERIAL);  //clr screen

delay_ms(10);

fputc(14,SERIAL);  //turn on backlight

delay_ms(10);

//fputc('A',SERIAL);  //send SINGLE character "A" to display
//fputc('2',SERIAL);  //sends a SINGLE character "2" to display
//fputs("DATA = ",SERIAL);   //sends a string to the display

fprintf(SERIAL,"%u"X);  //sends integer to lcd

delay_ms(500);

}
   
}


This last try sent a nice 255 to the display. Next I try int16 and maybe float...
temtronic



Joined: 01 Jul 2010
Posts: 9174
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jan 01, 2015 7:03 pm     Reply with quote

If you press F11 while your project is open, then the CCS C manual 'magically' appears. Gives you near instant access to answer most of your questions.
You can '-' to minimize it,very handy especially print formatting,options to use rs232(...) , etc.


hth
jay
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group