??? 02/16/07 10:12 Read: times |
#133115 - Start and end sentinel ! Responding to: ???'s previous message |
I've changed the ISR. i'm looking for start and stop.
if the character read it's not start i erase the location(of my_byte) if it's start i increment the location if it's stop i stop the interrupts (EA=0) void intr (void) interrupt 2 { port1=(~P1)&0x01; my_byte[i]=my_byte[i]<<1; my_byte[i]=my_byte[i]+port1; //writing bit in byte nrb++; //increment number of bits if (nrb==5){ if (have_start==0)//we don't have a START yet { if (my_byte[i]==0x1A) //have we found a start? { if (i<14) { i++; } //found start so increment i have_start=1; } else //we don't have a start yet and this is not a start! { my_byte[i]=0x0; //we clear my byte } } else //we read a start in the past { if (my_byte[i]==0x1F) //byte read not end sentinel { have_stop=1; EA=0; } else{ if (i<14) { i++; } } } nrb=0; //set number of bits to 0 } } the results are sent to the PC with this: while1: c = _getkey (); for(j=0;j<=i;j++) { putchar ( my_byte[j]+48); my_byte[j]=0x0; } have_start=0; have_stop=0; nrb=0; i=0; EA=1; //start again the global intterupt service goto while1; the result is this i = number of bytes ( locations in my_byte[]) (first 3 readings with a card, then with another card) J is start sentinel and o is end sentinel i can't explain what happend with readings 2,4,6,8 i:4 J1@=O i:0 0 i:4 J1@=O i:0 1 i:4 J112O i:0 1 i:4 J112O i:0 1 |