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 13:40
Modified:
  02/14/07 14:04

Read: times


 
#132895 - done that; same thing + the code
Responding to: ???'s previous message
i've changed 48 to '0'...
i don't get it... sometimes it reads the data correctly sometimes it doesn't. i don't find a rule here...maybe i'm missing something
when the data readen is wrong, each time it's wrong it's the same...it's not something random!


#include <reg51.h>
#include <stdio.h>

//extern void init(void);
unsigned char port1;
//sbit p3_b7 = port3 ^ 7;
unsigned char nrb=0;
unsigned char byte_meu[40];
unsigned char i=0;


void alarm (void) interrupt 2 //enters when clock signal comes from card reader
{
if (i>30) EA=0;//after 30 characters we stop the interrupt
port1=(~P1)&0x01; //reading data pin from P1, bit 1
byte_meu[i]=byte_meu[i]<<1;
byte_meu[i]=byte_meu[i]+port1; //writing in a byte
nrb++;
if (nrb==5){ //go to the next location after 5 bits
i++;
nrb=0; //reset bit counter
}
}

init_all() //serial init
{
SM1=1;
REN=1;
TMOD=0x20;
TH1=0xFD; //=253
TR1=1;
EA=1;
EX1=1;
IT1=1;
P1=255;
P3=255;
}


void main (void) {
char c;
unsigned char j;
init_all();
printf ("Hello World!!\n");
while1:

c= _getkey (); //wait for key
printf(" i:%d \n",i);
for(j=0;j<40;j++)
{
putchar ( byte_meu[j]+'0'); //send the data when key is pressed
byte_meu[j]=0x0; //clear the data after we send it
}


nrb=0; //clears number of bits and
i=0; //number of caracters read
EA=1; //enables interrupt

goto while1;

}

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