导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→农民求救呀 4442卡![农民]

 *第24464篇: 农民求救呀 4442卡!

  
楼 主:农民 2004年8月5日18:15
 农民求救呀 4442卡!
[color=#DC143C]

请教各位呀:
我农民好不容易去写一个4442卡的读写程序。我发出读卡的命令,那卡就是没能识别出这是读卡的命令。结果读出来都是1。为什么呀!
我用的是430单片机。
读卡程序:
void Read_main_ram(uchar Start_addr,uchar ByteCnt)
{
  uchar i=0;
  
  
  Start();
  SendByte(Control_word);
  SendByte(Start_addr);
  SendByte(0X00);
  Stop();
  
  for (i = 0; i   < ByteCnt; i++)      //读取ByteCnt个数据
  {
  Save_data_addr[i] = ReadByte();
  }
  Break();
}

uchar ReadByte(void)
{
  
  uchar Read_data = 0;
  uchar i    = 0; 
  
   
   P2DIR &= ~SDA;
  
  for (i = 0; i   < 8; i++ )
  {
    Read_data  = Read_data >  >  1;             
    
    CLK_1;
    DELAY(10);
    
    
    if (P2IN&SDA)
    {
       Read_data = Read_data | 0x80;
    }
    else
    {
       Read_data = Read_data & 0x7f;
    } 
    
    
    CLK_0;
    DELAY(10);       
  }
  
  return Read_data; 
}
void SendByte(uchar Data)
{
  uchar i = 0;
  uchar Data_temp;
  uchar Temp; 
  
  SDA_OUT;
  
  
  for ( i = 0; i   < 8; i++)            //8位数据
  {
    Data_temp = Data;
    Temp = 0X01&(Data_temp >  >   i);
    if(Temp)
    {
      SDA_1;
    }
    else
    {
      SDA_0;
    }
    clock();       
  }
}

 
 
[/color]

  
2楼:kerrigan 2004年8月6日10:58
 你信箱多少?我给你把软件包发过去

>>>>>>对该主题发表你的看法

本主题贴数2,分页: [第1页]


[上一篇主题]:怎样学好VHDL???

[下一篇主题]:[求助]单片机多机通信问题