在线时间0 小时
UID326999
ST金币0
蝴蝶豆0
注册时间2011-11-7
新手上路
- 最后登录
- 2019-1-8
|
a0a.1 0b0c
用STM32F10+ST8024读IC卡,但是总是没有ATR过来
很奇怪!用的是ST demo程序里面的smartcard.c/.h
如下是MCU脚的配置,pin11接的是ST8024的OFF,pin15是插IC卡中断拉PRES。
TX用的是PB.10, CLK PB.12
#define SC_3_5V GPIO_Pin_14
#define SC_RESET GPIO_Pin_12
#define SC_CMDVCC GPIO_Pin_13
#define SC_OFF GPIO_Pin_11
其他如UART3的设置主要是smartcard.c里面init设置,无改动。
NVIC_InitTypeDef NVIC_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOD|RCC_APB2Periph_AFIO, ENABLE);
/* Configure Smartcard CMDVCC */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_SetBits(GPIOD, GPIO_Pin_13);
/* Configure Smartcard OFF */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* Configure one bit for preemption priority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
/* Clear the SC_EXTI_IRQ Pending Bit */
NVIC_ClearIRQChannelPendingBit(EXTI15_10_IRQChannel);
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the USART3 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_Init(&NVIC_InitStructure);
/* Smartcard OFF Pin */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource11);
/* Clear SC EXTI Line Pending Bit */
EXTI_ClearITPendingBit(EXTI_Line11);
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_Line = EXTI_Line11;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
EXTI_GenerateSWInterrupt(EXTI_Line11);
//PB15
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
/* Clear EXTI Line Pending Bit */
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource15);
EXTI_ClearITPendingBit(EXTI_Line15);
//PB15 IC卡插入中断
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_Line = EXTI_Line15;
EXTI_Init(&EXTI_InitStructure);
EXTI_GenerateSWInterrupt(EXTI_Line15);
//PD15
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_SetBits(GPIOD, GPIO_Pin_15);
} |
|