Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

dsPIC33/PIC24 Family Reference Manual
DS70000582E-page 48 2009-2013 Microchip Technology Inc.
15.3 Smart Card Register Settings
The Smart Card communication protocol features are set using the UxSCCON register and the
Smart Card communication interrupts are set using the UxSCINT register. The guard and waiting
times are set using UxGTC and UxWTCL/UxWTCH registers, respectively, in units of ETU.
15.4 Smart Card Interrupt Configuration
The UART has the ability to generate interrupts reflecting the events that occur during the data
communication with the Smart Card. These interrupts can be controlled using the enable bits in
the UxSCINT register (see Register 15-2). The Smart Card protocol-specific interrupt flag status
bits can be read from the UxSCINT register and should be cleared in software.
Smart Card interrupts should be serviced in the UART error Interrupt Service Routine (ISR).
UART error interrupts must be enabled using the UxERIE bit (IECx<x>). The priority of the UART
error interrupt has to be set using UxERIP bit (IPCx<2:0>).
Example 15-1: Smart Card Interrupt Setup for UART1
15.5 Smart Card Communication
15.5.1 PRE-Answer-To-Reset (ATR) INITIALIZATION
The module should be configured in Receive mode prior to the Reset line being pulled low to
initiate the Smart Cards response as follows:
1. Write the UxBRG register with a value corresponding to REFO/372.
2. Configure for 8-bit data, even parity, by writing PDSEL<1:0> (UxMODE<2:1>) = 11.
3. Set the SCEN bit (UxSCCON<0>).
4. Set the URXEN bit (UxSTA<12>).
5. Set up and enable the RX interrupt as described in Section 7.3 “Receive Interrupt”.
6. Enable the UART by setting the UARTEN bit (UxMODE<15>).
7. Read data out of UxRXREG as it becomes available and save for ATR processing.
Note: Smart Card bit rate (ETU) is configured by writing the appropriate value to the
UxBRG register.
// Smart card interrupt setup for UART1
U1SCINTbits.GTCIF = 0; // Clear GTC interrupt flag
U1SCINTbits.GTCIE = 1; // Enable guard time count match interrupt
U1SCINTbits.WTCIF = 0; // Clear WTC interrupt flag
U1SCINTbits.WTCIE = 1; // Enable wait time count match interrupt
U1SCINTbits.TXRPTIF = 0; // Clear TX repeat error interrupt flag (Optional)
U1SCINTbits.TXRPTIE = 1; // Enable TX repeat error interrupt (Optional)
U1SCINTbits.RXRPTIF = 0; // Clear TX repeat error interrupt flag (Optional)
U1SCINTbits.RXRPTIE = 1; // Enable RX repeat error interrupt (Optional)
U1STAbits.PERR = 0; // Clear Parity error flag (Optional)
U1SCINTbits.PARIE = 1; // Enable RX parity error interrupt (Optional)
// UART 1 Error interrupt
IPC16bits.U1ERIP = 5; // Error interrupt priority
IFS4bits.U1ERIF = 0; // Clear U1 error flag
IEC4bits.U1ERIE = 1; // Enable error interrupts

e-Highlighter

Click to send permalink to address bar, or right-click to copy permalink.

Un-highlight all Un-highlight selectionu Highlight selectionh