awakebaby
驱动牛犊
驱动牛犊
  • 注册日期2004-07-28
  • 最后登录2004-08-04
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:851回复:0

simens SLE4428复位应答问题求助

楼主#
更多 发布于:2004-07-29 18:23
我在做一个读卡器的驱动
前两批4428卡都很正常(复位应答 读 写)
第三批4428卡(在其他读卡器上很正常) 复位应答返回的4字节大部分都为错误:(0XFF 0xFF, 0xFF,0xFF), 偶尔也是正确的:(0x92, 0x23, 0x10, 0x91)

我严格按照4428 datasheet上的ATR时序
且使用各种长度的延时后还是没有改观,
而且还发现一个现象,在单步调试下:
1。先插前两批卡中的任意一张卡,
2。在上完电后,(设断点)拔出卡,
3。再插第三批卡的任意一张,ATR的4字节总是正确的:
   (0x92, 0x23, 0x10, 0x91)

有做过的给指点指点,我的复位程序如下:
注: DELAY(1)===== 延时1 uS, 我曾经写了个延时时间为0到1000的循环,结果还是不正确



/************************API For IC Card************************/

static unsigned char read_data()
{    
unsigned char rd_data=0;
unsigned char sdio_value;
unsigned char count;
SetICIoRead;
for(count=0;count<8;count++)
    {
      rd_data >>= 1;
      SetIC_Clk_H;
      DELAY(10);
      sdio_value=Read_Bit_Data; //read data from io
      SetIC_Clk_L;
      DELAY(10);
      if(sdio_value==1)rd_data|=0x80;
      else{rd_data&=0x7f;}
    }
      return(rd_data);
}

/*******************************************************/
/*9. reads 32 bit ISO
stasndard response to reset      */
/*******************************************************/

static void ISO_no_read(unsigned char *str)
{
unsigned char count1;
SetICIoRead;
SetIC_RST_H;
     DELAY(10);
SetIC_Clk_H;
DELAY(20);
SetIC_Clk_L;
DELAY(20);
     SetIC_RST_L;
     DELAY(10);
     for (count1=0; count1<4; count1++)
str[count1]=read_data();
//   SetIC_RST_H;
// DELAY(10);
// SetIC_RST_L;
 }


/************************API For IC Card************************/
int SLE_S2_recognise(void)
{
const unsigned char coding_16bit[4] = {0x92, 0x23, 0x10, 0x91};
unsigned char IC_ATR[4] = {0x0, 0x0, 0x0, 0x0};
int IC_type = -1;

           IC_PowerOn();

SetIC_RST_L;
DELAY(10);
SetIC_Clk_L;
DELAY(10);
ISO_no_read(IC_ATR);

if ((IC_ATR[0] == coding_16bit[0] && IC_ATR[1] == coding_16bit[1])
|| (IC_ATR[0] == coding_ext_1[0] && IC_ATR[1] == coding_ext_1[1])
|| (IC_ATR[0] == coding_ext_2[0] && IC_ATR[1] == coding_ext_2[1])) {
IC_type = SLE_4428;
}
IC_PowerDown();
return IC_type;
}

void IC_PowerOn(void)
{
SetIC_Clk_H;
DELAY(20);
     SetIC_RST_H;

           SetPowerOn;
  DELAY(80);
}

void IC_PowerDown()
{  
SetIC_Clk_H;
DELAY(20);
     SetIC_RST_H;

DELAY(300);
           SetPowerDown;
}


大伙儿帮帮忙啊!谢了
游客

返回顶部