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

why japanese char?

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








why japanese char?
PostPosted: Mon Apr 20, 2009 2:55 am     Reply with quote

Hai!! All. I have 2 problems

First my LCD display Japanese character. Second, My code stuck on LCD display Card Invalid when I move a card. Suppose LCd show CardNot Detected.

This is my code:

Code:
#include<16f877A.h>

#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP

#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,ERRORS)
#include<flex_lcd.c>

#define cardSta PIN_B5
#define LED1 PIN_B4
#define LED2 PIN_B3

char SelectCard[4]       = {0xBA,0x02,0x01,0xB9};
int8 ctr;
char rbuff[10];

void main() {



lcd_init();
lcd_putc("\fhai!!");
delay_ms(3000);

while(1){

//****************************************************************************

   if(input(cardSta)==0) {

   lcd_putc("\fcard detected\ntry");
      output_high(LED1);
      delay_ms(500);
      output_low(LED1);
      delay_ms(500);
   for (ctr=0;ctr<4;ctr++) putc(SelectCard[ctr]); //send command SelectCard


   if(kbhit())

   for (ctr=0;ctr<10;ctr++) rbuff[ctr]=getc(); //receive 10 response bytes
   lcd_putc("\f");
   for (ctr=0;ctr<10;ctr++)
   lcd_putc(rbuff[ctr]);
   delay_ms(10000);

   if (rbuff[3]==0 && rbuff[8]==1) {
   lcd_putc("\fMifare Card "); // to show that the card accepted
 
   }
   else {

   lcd_putc("\fCard Invalid");
   break;
   }
   }

   else {

   lcd_putc("\fcardNotDetected\ntry");
      output_high(LED2);
      delay_ms(500);
      output_low(LED2);
      delay_ms(500);

   }

}
}


I seen on forum some user use this:

Quote:
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN

I not understand about PLL5, CPUDIV1, VREGEN. Is it need for my code?

Suppose I receive 10 bytes respond, not a japanese character


Help pls.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 20, 2009 11:47 am     Reply with quote

Post the manufacturer and part number of your LCD and your card
reader. Also post a list of the connections between the PIC and those
two devices.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Apr 20, 2009 3:03 pm     Reply with quote

Code:
   for (ctr=0;ctr<4;ctr++) putc(SelectCard[ctr]); //send command SelectCard


   if(kbhit())

   for (ctr=0;ctr<10;ctr++) rbuff[ctr]=getc(); //receive 10 response bytes
   lcd_putc("\f");
I'm not sure what you want to do here, but it is not going to work.

There is no ';' or '{' after the kbhit line which means that your code is equivalent to:
Code:
   for (ctr=0;ctr<4;ctr++) putc(SelectCard[ctr]); //send command SelectCard

   if(kbhit())
   {
      for (ctr=0;ctr<10;ctr++) rbuff[ctr]=getc(); //receive 10 response bytes
   }
   lcd_putc("\f");
The card reader must respond within a few microseconds or the kbhit test will fail and the 10 respond bytes will never be received. The baudrate is 9600 baud, or about 1ms for a byte so it is impossible to ever meet this quick response time.

Solve by removing the kbhit test, it is not needed.
Guest








PostPosted: Wed Apr 29, 2009 1:06 am     Reply with quote

I try to display this 0xBA,0x02,0x01,0xB9 four byte number to my lcd but the lcd display four character like this @#$%. The four byte number that I want to display came from char SelectCard[4] = {0xBA,0x02,0x01,0xB9}; in my code.

I'm using 16*2 lcd and compiler version 3.214

Plz help. This is my code:



Code:
#include<16f877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,ERRORS)
#include<flex_lcd.c>
#define cardSta PIN_B5
#define LED1 PIN_B4
#define LED2 PIN_B3

char SelectCard[4]       = {0xBA,0x02,0x01,0xB9};
int8 ctr;

void main() {

lcd_init();
lcd_putc("\fhai!!");
delay_ms(3000);

while(1){

   if(input(cardSta)==0) {

   lcd_putc("\fcard detected");
      delay_ms(500);

   lcd_putc("\f");
   for (ctr=0;ctr<4;ctr++){
   lcd_putc(SelectCard[ctr]);
   delay_ms(1000);
   }
   }

   else {

   lcd_putc("\fcardNotDetected");
      output_high(LED2);
      delay_ms(500);
      output_low(LED2);
      delay_ms(500);

   }

}
}
Guest








PostPosted: Wed Apr 29, 2009 3:52 am     Reply with quote

I just got the solution. Only use command printf(lcd_putc,"%X",SelectCard[crt]); to replace lcd_putc(SelectCard[ctr]);
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