disketto wrote on Wednesday, June 12, 2013:
Hello,
i post my functions here, this is my usart1 setting code:
#define USART_MODE_ISO7816_T0 (AT91C_US_USMODE_ISO7816_0 | AT91C_US_CLKS_EXT | AT91C_US_CHRL_8_BITS | AT91C_US_PAR_EVEN | AT91C_US_NBSTOP_2_BIT | AT91C_US_CKLO)
#define BOARD_PIN_USART_RXD PIN_USART1_RXD
#define BOARD_PIN_USART_TXD PIN_USART1_TXD
#define BOARD_PIN_USART_CTS PIN_USART1_CTS
#define BOARD_PIN_USART_RTS PIN_USART1_RTS
#define BOARD_USART_BASE AT91C_BASE_US1
#define BOARD_ID_USART AT91C_ID_US1
#define BOARD_ID_SMART AT91C_ID_US1
#define PINS_ISO7816_SMART PIN_USART1_TXD, PIN_USART1_SCK, PIN_ISO7816_RST_SMART, PIN_SMART_CONF_A, PIN_SMART_CONF_B
xComPortHandle xSmartPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
{
xComPortHandle xReturn = ( ( xComPortHandle ) 2 );
extern void ( vUART_ISR )( void );
const Pin xUSART_Pins = { PINS_ISO7816_SMART };
/* Create the queues used to hold Rx and Tx characters. */
xRxedISOChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed char ) );
xTxedISOChars = xQueueCreate( uxQueueLength + 1, ( unsigned portBASE_TYPE ) sizeof( signed char ) );
/* If the queues were created correctly then setup the serial port
hardware. */
if( ( xRxedISOChars != serINVALID_QUEUE ) && ( xTxedISOChars != serINVALID_QUEUE ) )
{
portENTER_CRITICAL();
{
/* Enable the peripheral clock in the PMC. */
PMC_EnablePeripheral( BOARD_ID_SMART );
/* Configure the USART. */
USART_Configure( BOARD_SMART_BASE, USART_MODE_ISO7816_T0, ulWantedBaud, configCPU_CLOCK_HZ );
/* Configure the interrupt. Note the pre-emption priority is set
in bits of the priority value passed as the parameter. */
IRQ_ConfigureIT( BOARD_ID_SMART, ( configMAX_SYSCALL_INTERRUPT_PRIORITY << 8 ), USART1_IrqHandler );
IRQ_EnableIT( BOARD_ID_SMART );
/* Configure IO for USART use. */
PIO_Configure( xUSART_Pins, PIO_LISTSIZE( xUSART_Pins ) );
}
portEXIT_CRITICAL();
}
else
{
xReturn = ( xComPortHandle ) 0;
}
/* This demo file only supports a single port but we have to return
something to comply with the standard demo header file. */
return xReturn;
}
where USART_Configure is:
void USART_Configure(AT91S_USART *usart,
unsigned int mode,
unsigned int baudrate,
unsigned int masterClock)
{
// Reset and disable receiver & transmitter
usart->US_CR = AT91C_US_RSTRX | AT91C_US_RSTTX
| AT91C_US_RXDIS | AT91C_US_TXDIS;
// Configure mode
usart->US_MR = mode;
usart->US_IDR = -1;
usart->US_FIDI = 372;
// Configure baudrate
// Asynchronous, no oversampling
if(mode==USART_MODE_ISO7816_T0){
usart->US_BRGR = (masterClock / 3571200);
}
USART_SetTransmitterEnabled(usart, 1);
USART_SetReceiverEnabled(usart, 1);
// TODO other modes
}
where i didn’t report the macro, is used the standard value as freeRTOS did.
It could be something missing in the USART_Configure ?
So i expected to find the clock signal on the PA24, since i enabled it with PMC_EnablePeripheal(), but can’t see anything.
Thanks in advance for the reply,
Vito Vecchio