I'm trying to enable SmartCard mode for SD3, everything looks fine except my application not receive any data from IO line.
In oscilloscope I see that SIM card response with ATR.
That how I initialize serial port:
Code: Select all
/*
* Port C setup.
* Everything input with pull-up except:
* PC8 - Push Pull output (SMART_CARD1_RST).
* PC9 - Push Pull output (SMART_CARD1_3_5V).
* PC10 - Alternate open drain (SMART_CARD1_IO).
* PC11 - Normal input (SMART_CARD1_OFF).
* PC12 - Alternate output (SMART_CARD1_CLK).
* PC13 - Push Pull output (SMART_CARD1_VCC).
*/
#define VAL_GPIOCCRL 0x88888888 /* PC7...PC0 */
#define VAL_GPIOCCRH 0x883B4F33 /* PC15...PC8 */
#define VAL_GPIOCODR 0xFFFFFEFF
static SerialConfig scard1_serial_cfg = {
9677, // 3.6 MHZ / 372
USART_CR1_M | USART_CR1_PCE,
USART_CR2_CLKEN | USART_CR2_STOP1P5_BITS | USART_CR2_LBCL,
USART_CR3_SCEN | USART_CR3_NACK
};
...
AFIO->MAPR |= AFIO_MAPR_USART3_REMAP_PARTIALREMAP;
sdStart( &SD3, scard1_serial_cfg);
/* Clear the USART prescaler */
USART3->GTPR &= GTPR_MSB_Mask;
/* Set the USART prescaler */
// 36 HMz / 10 = 3.6 MHz clock for CmartCart ( 9677 b/s )
USART3->GTPR |= 0x05; // clock / 10 ; see datasheat
/* Clear the USART Guard time */
USART3->GTPR &= GTPR_LSB_Mask;
/* Set the USART guard time */
USART3->GTPR |= (uint16_t)((uint16_t)16 << 0x08);
// Here I powerup smartcart and waiting for ATR
if ( chSequentialStreamRead((BaseChannel *)&SD3, (uint8_t *)&atr, 40) )
{
DBGHEXDUMP(DBG_TRACE,atr,0,40,"Got ART");
sleep(60000);
}
Thanks.