Hi,
in first sorry for my english....
I have a problem with my smart card 16f877 when I send data , it repeat the same data :
example :
when i send AAAAAAA with my card reader to my card , he must to response only BB , but it response AAAAAAABB
Here is the sendbyte function (i use PCWH compiler )
main()
{
......
sendByte("0xBB");
......
}
void sendByte(int iSendData)
{
int iParity;
int iCtr;
int iPauseCtr;
#asm
movlw 0x32 ; Pause for 170 ?s
call Pause ; call Pause
bcf PORTB,7 ; Send start bit in RB7
movlw 0x7F
tris PORTB ; TRIS PORB with 01111111 (0x7F)
clrf iParity ; Initialize Parity to 0
movlw 0x08
movwf iCtr ; Initialize 8 to counter to send 8 data bits
send_loop:
call Std_pause ; Pause for 93 ?s (at 9600 bps)
rrf iSendData,f
rrf iSendData,W
andlw 0x80
xorwf iParity,f ; Calculate Parity
xorwf PORTB,W
xorwf PORTB,f
decfsz iCtr,f ; Decrement Data Bit counter
goto send_loop ; Loop
call Std_pause ; Pause
movf iParity,W ; Send Parity
xorwf PORTB,W
xorwf PORTB,f
call Std_pause
movlw 0xFF
tris PORTB
movlw 0x3E
goto Pause ; Pause 0x3E
return
Std_pause:
movlw 0x1A ; Standard Pause Value
Pause:
movwf iPauseCtr ; Initialize iPauseCounter with value of W Register
Pause_loop:
decfsz iPauseCtr,f ; Decrement Pause Counter
goto Pause_loop
#endasm
}
I have read many topic but I found nothing.
Please help me , how can i flush input data register before response
?
Many thanks in advance.
Regards,