usart can't entry interrupt function

Discussion around products based on ARM Cortex-A5 core.

Moderator: nferre

leo.ni
Posts: 52
Joined: Mon Jun 06, 2016 4:20 am

usart can't entry interrupt function

Tue Mar 28, 2017 10:03 am

hi,all. i use sama5d3 and configure usart1 as follow,but my program can't entry timeout interrupt function. Can someone give me some advice?Thanks !

Code: Select all

static void USART1_IrqHandler( void )
{
  printf( "here, usart1 interrupted\r\n" );
}

static void _configureUsart( void *pInstance )
{ 
    const uint16_t receivedTimeOut = 500;
    assert( NULL != pInstance );
    
    DataSource *pSource = ( DataSource * )pInstance;
    Usart *pUsart = ( Usart * )pSource->dev.instanceHandle;
    
    uint32_t mode =     US_MR_USART_MODE_NORMAL
//    uint32_t mode =     US_MR_USART_MODE_HW_HANDSHAKING
                        | US_MR_USCLKS_MCK
                        | US_MR_CHRL_8_BIT
                        | US_MR_PAR_NO
                        | US_MR_NBSTOP_1_BIT
                        | US_MR_CHMODE_NORMAL ;

    /* Enable the peripheral clock in the PMC*/
    PMC_EnablePeripheral( pSource->dev.identify );

    /* Configure the USART in the desired mode @115200 bauds*/
    USART_Configure( pUsart, mode, 115200, BOARD_MCK ) ;

    /* Configure the interrupt */
    USART_SetReceivedTimeout( pUsart,receivedTimeOut );    
		/* Configure the interrupt */
    USART_EnableIt(pUsart,( 1 << 8 ) );
    
    if( pSource->dev.identify == ID_USART0 )
          IRQ_ConfigureIT( ID_USART0, 0, USART0_IrqHandler );
    else if( pSource->dev.identify == ID_USART1 )
         IRQ_ConfigureIT( ID_USART1, 0, USART1_IrqHandler );  
    else
      ;
    
    /* Enable receiver & transmitter*/
    USART_SetTransmitterEnabled( pUsart, 1 ) ;
    USART_SetReceiverEnabled( pUsart, 1 ) ;

}

void usart_init( void *pInstance , void *parameter )
{
      assert( NULL != pInstance );
      
      parameter = parameter;
      
      static const Pin pins0[] = { PINS_USART0 };
      static const Pin pins1[] = { PINS_USART1 };
      
      DataSource *pSource = ( DataSource * )pInstance;
      
      if( pSource->dev.identify == ID_USART0 )
      {
          /* Configure pins*/
          PIO_Configure( pins0, PIO_LISTSIZE( pins0 ) ) ;
      }
      else
      {
          PIO_Configure( pins1, PIO_LISTSIZE( pins1 ) ) ;
      } 
      
      _configureUsart( pInstance );           
}

uint8_t usart_read( void )
{
    return usart->US_RHR;
}

Return to “SAMA5D Cortex-A5 MPU”

Who is online

Users browsing this forum: No registered users and 1 guest