打印
[应用相关]

请教香主,PC卡控制问题。

[复制链接]
1880|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wuxbfl|  楼主 | 2010-9-29 12:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我使用的STM32F103ZCT6 芯片,PC卡使用的CAM(条件接收卡,8位PC卡兼容),硬件接线:
              FSMC                 PC 卡
              A0--A13            A0--A13
              D0--D7             D0--D7
              NEC4_1             CE1
              NIOIS16(接地)     --
              NREG                 NREG
              NIORD                NIORD
              NIOWR               NIOWR
              NOE                   NOE
              NWE                  NWE
              CD                     CD
软件:使用的固件库中提供的结构,初始化如下
        void PCCARD_IO_Init(void)                                             
{                                                                     
    GPIO_InitTypeDef GPIO_InitStructure;  
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All&&(!GPIO_Pin_6);
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                  
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AF_PP;                     
GPIO_Init(GPIOD, &GPIO_InitStructure);                                                                    

        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;//NWAIT
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                  
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_IPU;//GPIO_Mode_IPU;                     
GPIO_Init(GPIOD, &GPIO_InitStructure);      
        
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                  
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AF_PP;//GPIO_Mode_AF_PP;                     
GPIO_Init(GPIOE, &GPIO_InitStructure);                              

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All&&(!(GPIO_Pin_9|GPIO_Pin_11));
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                  
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AF_PP;//GPIO_Mode_AF_PP;                     
GPIO_Init(GPIOF, &GPIO_InitStructure);

        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;//CD1
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                  
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_IPU;//GPIO_Mode_AF_PP;                     
GPIO_Init(GPIOF, &GPIO_InitStructure);
        
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;//NIOS16
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                  
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_IN_FLOATING;//GPIO_Mode_AF_PP;                     
GPIO_Init(GPIOF, &GPIO_InitStructure);
        
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                  
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AF_PP;//GPIO_Mode_AF_PP;                     
GPIO_Init(GPIOG, &GPIO_InitStructure);               
         
        GPIO_InitStructure.GPIO_Pin =GPIO_Pin_12; //CD2#
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                  
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_IPU;//;                     
GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin =GPIO_Pin_10|GPIO_Pin_9; //RDX1 TXD1
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                  
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AF_PP;//;                     
GPIO_Init(GPIOA, &GPIO_InitStructure);
                              
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_8; //OE1
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                  
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_Out_PP;//;                     
GPIO_Init(GPIOA, &GPIO_InitStructure);                             
/*OE2,OE3,OE4,OE5*/
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                  
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_Out_PP;//;                     
GPIO_Init(GPIOC, &GPIO_InitStructure);   
/*PRESET,CAM_PWR*/
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_15|GPIO_Pin_14;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                  
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_Out_PP;//;                     
GPIO_Init(GPIOB, &GPIO_InitStructure);
/*I2C_SMBA1,RXD3/SDL,TXD3/SDA*/
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                  
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AF_PP;//;                     
GPIO_Init(GPIOB, &GPIO_InitStructure);     
      
}  
void PCCARD_FSMCConfig(void)
{
FSMC_PCCARDInitTypeDef FSMC_PCCARDInitStructure;
FSMC_NAND_PCCARDTimingInitTypeDef p;
p.FSMC_SetupTime = 3;
p.FSMC_WaitSetupTime = 3;
p.FSMC_HoldSetupTime = 3;
p.FSMC_HiZSetupTime = 0;
//FSMC_PCCARDInitStructure.FSMC_Bank = ;
FSMC_PCCARDInitStructure.FSMC_Waitfeature = FSMC_Waitfeature_Disable; //禁止等待
FSMC_PCCARDInitStructure.FSMC_AddressLowMapping = FSMC_AddressLowMapping_Direct;//低地址直接映射
        //
        FSMC_PCCARDInitStructure.FSMC_PWID = FSMC_MemoryDataWidth_16b;//数据宽度16位,STM32只能16位访问
        FSMC_PCCARDInitStructure.FSMC_PTYP = FSMC_MemoryType_PCCARD;//卡类型为PCCARD
   
       FSMC_PCCARDInitStructure.FSMC_TCLRSetupTime = 0x0;
FSMC_PCCARDInitStructure.FSMC_TARSetupTime = 0x0;
FSMC_PCCARDInitStructure.FSMC_CommonSpaceTimingStruct = &p;
FSMC_PCCARDInitStructure.FSMC_AttributeSpaceTimingStruct = &p;
FSMC_PCCARDInitStructure.FSMC_IOSpaceTimingStruct = &p;
FSMC_PCCARDInit(&FSMC_PCCARDInitStructure);
FSMC_PCCARDCmd(ENABLE);
}
2、我的测试程序如下:
#define PCCARD_reg_base   0x98000000  
#define PCCARD_io_base   0x9c000000
RCC_Configuration();
NVIC_Configuration();

PCCARD_IO_Init();
PCCARD_FSMCConfig();
Delay(300);
GPIO_SetBits(RESET_PORT, RESET);//对卡reset
Delay(300);
GPIO_ResetBits(RESET_PORT, RESET);

*(u16*)(PCCARD_io_base ) = N;//这句可运行,但控制线,地址,数据线状态不对
  *(u16*)(PCCARD_reg_base ) = N;//此句运行后,程序就进入FaultISR中去了。
N = *(u16*)(PCCARD_io_base );
N = *(u16*)(PCCARD_reg_base );
请各位高手帮我看看,是什么原因?还有一事请教,PC卡的读写模式(IO模式(IOWR,IORD),属性模式(OE,WR),)是使用不同的地址,STM32就能产生不同的读写控制信号吗?
沙发
香水城| | 2010-9-29 13:31 | 只看该作者
不好意思,没做过这个,你问问其他人吧。

使用特权

评论回复
板凳
lhy317409772| | 2015-1-15 10:26 | 只看该作者
请问兄弟有没有把PCCard模式搞定??   求指导,谢谢。
   能不能加您扣扣?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

4

主题

12

帖子

0

粉丝