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

LCD 16x2 doesn't receive last bit

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



Joined: 20 Jul 2006
Posts: 29

View user's profile Send private message Send e-mail MSN Messenger

LCD 16x2 doesn't receive last bit
PostPosted: Tue Jul 17, 2007 6:09 am     Reply with quote

Hi everyone.
I have a problem when trying to use a 16X2 lcd with the CCS lcd driver. I have already verified all the connections, but they are all ok. I wrote the following lines:

Code:
#include <16F689.h>
#device adc=8
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES XT                       //Crystal osc <= 4mhz
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOMCLR                   //Master Clear pin used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#use delay(clock=4000000)
#include <lcd.c>

void main()
{
lcd_init();
printf(lcd_putc,"\fabcdefghklmnopqr");

while (true){
output_high(PIN_B7);   //this is a led pin
delay_ms(100);
output_low(PIN_B7);
delay_ms(100);
}}


but the result I got in the LCD was "`bbddffhjllnn``b" instead of "abcdefghklmnopqr". I've consulted the ascii table and I realized that the binary code for "a" is "0110 0001" and the code for "`" is "0110 0000", i.e., the difference is in the last bit. It should be sent as a 1, but it was sent as a 0. This happens for the other letters and it is interesting that the code for "p" is "0111 0000". The only difference between "p" and "`" is the last bit for the first part of the byte. The same for the "q" and the "r". So, as the driver sends by nibble mode, I suspected that there might be a problem with the connection of the last pin bit. But, it is ok!!
I don't know what to do. Does anyone have any suggestion?
I use PIC16F689 and the connections are the following:
PIN_C4-->LCD_D4
PIN_C5-->LCD_D5
PIN_C6-->LCD_D6
PIN_C7-->LCD_D7
PIN_C0-->LCD_EN
PIN_C1-->LCD_RS
PIN_C2-->LCD_RW

I tried the flexlcd driver already posted here. It didn't work. It hasn't showed anything. Even after changing the delay_ms(15) to a delay_ms(50).

The version of my CCS is
IDE 4.010, PCB, PCM and PCH 4.013.

I have searched the forum for a similar problem, but I still haven't found it. Any help would be of great value.

Thanks,
Otávio Gomes.
Bill Boucher



Joined: 04 Feb 2005
Posts: 34
Location: Chatham,ON,CA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Jul 17, 2007 9:50 am     Reply with quote

Add the following line to your powerup or initialization section:
Code:
setup_comparator(NC_NC_NC_NC); // kill comparators

The 16F689 has comparators and they are on by default. The comparator output on PIN_C4 may be overriding your LCD data.

Good luck.

As follows:
Code:

void main()
{
setup_comparator(NC_NC_NC_NC); // kill comparators
lcd_init();
printf(lcd_putc,"\fabcdefghklmnopqr");

while (true)
  {
   output_high(PIN_B7);   //this is a led pin
   delay_ms(100);
   output_low(PIN_B7);
   delay_ms(100);
  }
}
otavio_fisica



Joined: 20 Jul 2006
Posts: 29

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Tue Jul 17, 2007 1:46 pm     Reply with quote

Thank you very much. Now it works correctly. I knew there was something happening with the pin but I couldn't realize what it was... thank you again... very much.
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