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 CCS Technical Support

LCD and PIC16f876A

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



Joined: 16 Mar 2004
Posts: 2

View user's profile Send private message

LCD and PIC16f876A
PostPosted: Tue Mar 16, 2004 11:19 am     Reply with quote

Hi, we are stuck at this problem we are trying to print some text on the lcd
type KS0066U


the lcd driver doesn't work so we wrote our own, we are using 8bit communication.

the lcd starts up but it writes some of the message wrongly, every second letter is correct.

please need some help fast, we are getting mad on this peace of #%"#&%"#&

Code:

#include <16F876A.h>


#fuses HS, NOWDT, NOBROWNOUT, NOPUT,NOPROTECT

#use delay (clock=20000000)


#byte tris_a=0x85

#byte tris_b=0x86

#byte port_a=0x05

#byte port_b=0x06

#define forever while(2<3);

#define ascii port_b
 
void writetxt(char* text);

main()
{
   int i=0;
   char strang[20];

   set_tris_b(0x00);         /* 1 => input, 0 => output */

   set_tris_a(0x00);         /* alla output */

   delay_ms(2000);


   OUTPUT_HIGH(PIN_A0);      // RS=1
   OUTPUT_HIGH(PIN_A1);      // R/W=1
   OUTPUT_LOW(PIN_A2);      // E=0
   delay_ms(1);         

   OUTPUT_LOW(PIN_A0);      // RS=0
   OUTPUT_LOW(PIN_A1);      // R/W=0
   delay_us(1);   

   OUTPUT_HIGH(PIN_A2);      // E=1
   delay_us(1);

   ascii = 0x3F;

   OUTPUT_LOW(PIN_A2);      // E=0
   delay_us(139);
   delay_us(1);
   OUTPUT_HIGH(PIN_A0);      // RS=1
   OUTPUT_HIGH(PIN_A1);      // R/W=1
   delay_us(1);

   OUTPUT_LOW(PIN_A0);
   OUTPUT_LOW(PIN_A1);
   delay_us(1);   
   OUTPUT_HIGH(PIN_A2);
   delay_us(1);

   ascii = 0x0F;

   OUTPUT_LOW(PIN_A2);      // E=0
   delay_us(139);
   delay_us(1);
   OUTPUT_HIGH(PIN_A0);      // RS=1
   OUTPUT_HIGH(PIN_A1);      // R/W=1
   delay_us(1);

   OUTPUT_LOW(PIN_A0);
   OUTPUT_LOW(PIN_A1);
   delay_us(1);   
   OUTPUT_HIGH(PIN_A2);
   delay_us(1);

   ascii = 0x01;

   OUTPUT_LOW(PIN_A2);      // E=0
   delay_us(139);
   delay_us(1);
   OUTPUT_HIGH(PIN_A0);      // RS=1
   OUTPUT_HIGH(PIN_A1);      // R/W=1
   delay_us(1);

   OUTPUT_LOW(PIN_A0);
   OUTPUT_LOW(PIN_A1);
   delay_us(1);   
   OUTPUT_HIGH(PIN_A2);
   delay_us(1);

   ascii = 0x07;

   OUTPUT_LOW(PIN_A2);      // E=0
   delay_ms(15);
   delay_us(1);
   OUTPUT_HIGH(PIN_A0);      // RS=1
   OUTPUT_HIGH(PIN_A1);      // R/W=1
   delay_us(1);

   delay_ms(1);   

   

   strcpy(strang, "Hello World");

   writetxt(strang);
}
 
void writetxt(char* text)
{
   int i = 0;
   while(text[i] != 0)
   {
      OUTPUT_HIGH(PIN_A0);
      OUTPUT_LOW(PIN_A1);
      delay_us(1);   
      OUTPUT_HIGH(PIN_A2);
      OUTPUT_LOW(PIN_A1);      // R/W=1

      delay_us(1);

      ascii = text[i++];

      OUTPUT_LOW(PIN_A2);      // E=0
      delay_ms(200);
      delay_us(1);
      OUTPUT_LOW(PIN_A0);      // RS=0
      OUTPUT_HIGH(PIN_A1);      // R/W=1
      OUTPUT_HIGH(PIN_A1);      // R/W=1

      delay_us(1);

      delay_ms(200);
   }
}

_________________
~The MATRIX~
Guest








PostPosted: Tue Mar 16, 2004 7:55 pm     Reply with quote

i was getting errors when i started. but i manged to fix it using a very technical method, i turned the lcd on its itside!!!

i guess i must have had a loose connection, but i checke dit a few times. maybe your connection is loose.
matrix2k



Joined: 16 Mar 2004
Posts: 2

View user's profile Send private message

PostPosted: Wed Mar 17, 2004 1:56 pm     Reply with quote

thanx will check that,,, i would apriciate if someone could test this code on their own lcd, so that we know if code works....

PIC: PIC16f876A
LCD: KS0066U

PORT B is data
port A0 is RS
port A1 is RW
port A2 is E

thanks again
_________________
~The MATRIX~
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