Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/14/07 09:18
Read: times


 
#132882 - Reading a ISO7811 card with AT89c2051
I'm trying to read a card using a AT89c2051 and a KDR1932 CardReader. i wrote the code in franklin software p roview (C).
the ideea: the ucontroller is waiting for the card. a interrupt occurs when the card reader is sending the clock signal. in the interrupt function i'm reading the data sent by the card reader:

port1=(~P1)&0x01; //reading P1 bit 1 (data pin)
my_byte[i]=my_byte[i]<<1;
my_byte[i]=my_byte[i]+port1;
nrb++; //number of bits
if (nrb==5){ //if nr of bits is 5 then I write in the next location of my_byte; in ISO 7811 each digit is 5 bits long, comprising
a 4-bit BCD digit and a parity bit.
i++;
nrb=0;
}
//end of interrupt function

in the main program i'am waiting for something to be received on the serial port then send the data.
while1:
c = getchar ();

for(j=0;j<40;j++)
{
printf ("%c", my_byte[j]+48); //i add 48 to the char so that it would be a readable character
byte_meu[j]=0x0;
}
nrb=0;
i=0;
goto while1;

so... somethimes the reading is good and sometimes the reading is bad. i can't figure out why.
for exemple:
1.i slide the card through card reader
2.press a key from my PC to send data to serial
3.i receive the correct data
4.i slide again the card through card reader
5.press a key from my PC to send data to serial
6.i receive wrong data

but if between readings (between steps 3 and 4) i clear the memmory again(my_byte) the data readen is correct!!

thank you!
PS if somebody wants to see the entire code i can send it to them


List of 24 messages in thread
TopicAuthorDate
Reading a ISO7811 card with AT89c2051            01/01/70 00:00      
   You need to clear my_byte[]!            01/01/70 00:00      
      i\'m already doing that            01/01/70 00:00      
         Clearer?            01/01/70 00:00      
            done that; same thing + the code            01/01/70 00:00      
               Difference between right and wrong..            01/01/70 00:00      
                  rigth and wrong            01/01/70 00:00      
                     Are those the actual results?            01/01/70 00:00      
                        here are the actual values            01/01/70 00:00      
                           Did you do as Russell suggested?            01/01/70 00:00      
                              I clear my_byte            01/01/70 00:00      
                                 I am Confused...            01/01/70 00:00      
                                    byte_meu is my_byte            01/01/70 00:00      
                           Look for the start sentinel            01/01/70 00:00      
                              Start and end sentinel !            01/01/70 00:00      
                                 Masking            01/01/70 00:00      
                                    incorrect readings when changing cards            01/01/70 00:00      
                                       Dont count bits until you have the sentinel!            01/01/70 00:00      
                                          Not necessarily garbage either....            01/01/70 00:00      
                                          THANKS !!!!! It works!!            01/01/70 00:00      
   Credit Card Reader Using a PIC12C509            01/01/70 00:00      
      How does your code work?            01/01/70 00:00      
         a bug ! and another problem            01/01/70 00:00      
      Credit Card Hex PIC12F629            01/01/70 00:00      

Back to Subject List