Skip to main content
Visitor II
June 24, 2010
Question

UART2 Interrupt

  • June 24, 2010
  • 3 replies
  • 759 views
Posted on June 24, 2010 at 10:36

Hello i'm port uart2 polling receive data from hyperterminal it's ok. but i need use uart2 receive data with interrupt?

  TIM3_DeInit();

 

  TIM3_TimeBaseInit(TIM3_PRESCALER_1,0xFFFF);

   TIM3_ITConfig(TIM3_IT_UPDATE, ENABLE);

    enableInterrupts();

    GPIO_Init(GPIOD, 0x01 , GPIO_MODE_OUT_PP_LOW_FAST);

       

    CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);

    UART2_DeInit();

    UART2_Init((u32)9600, UART2_WORDLENGTH_8D,    UART2_STOPBITS_1, UART2_PARITY_NO, UART2_SYNCMODE_CLOCK_DISABLE, UART2_MODE_TXRX_ENABLE);

    UART2_ClearITPendingBit(UART2_IT_RXNE);

    UART2_ITConfig(UART2_IT_IDLE, ENABLE);

this code incorrect i don't know use function and see a register please help me

    This topic has been closed for replies.

    3 replies

    Visitor II
    March 14, 2011
    Posted on March 14, 2011 at 09:43

    TIM3_DeInit();

    TIM3_TimeBaseInit(TIM3_PRESCALER_1,0xFFFF);

    TIM3_ITConfig(TIM3_IT_UPDATE, ENABLE);

    enableInterrupts();

    GPIO_Init(GPIOD, 0x01 , GPIO_MODE_OUT_PP_LOW_FAST);

    CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);

    UART2_DeInit();

    UART2_Init((u32)9600, UART2_WORDLENGTH_8D,    UART2_STOPBITS_1, UART2_PARITY_NO, UART2_SYNCMODE_CLOCK_DISABLE, UART2_MODE_TXRX_ENABLE);

    UART2_ClearITPendingBit(UART2_IT_RXNE);

    UART2_ITConfig(UART2_IT_IDLE, ENABLE);

    UART2_ITConfig(UART2_IT_RXNE_OR, ENABLE);

    Visitor II
    May 11, 2011
    Posted on May 11, 2011 at 13:47

    I´m in doubt if I need to use the UART2_ClearITPendingBit() function after read a byte from UART2 Interruption routine, or the own read action clears the pending bit RXNE. I couldn´t find this information from RM0016 reference manual.

    The code I´m using:

    #ifdef _COSMIC_

    @far @interrupt void UART2_RX_IRQHandler(void)

    #else /* _RAISONANCE_ */

    void UART2_RX_IRQHandler(void) interrupt 21

    #endif /* _COSMIC_ */

    {

      // Read one byte from the receive data register

      RxBuffer[RxCounter++] = UART2_ReceiveData8();

     

    UART2_ClearITPendingBit(UART2_IT_RXNE_OR); // Does this function is necessary?

      

      if(

    RxCounter==128)

        

       RxCounter=0;

      .

      .

      .

    }

    Visitor II
    May 11, 2011
    Posted on May 11, 2011 at 17:45

    I´ve already tested here,  that function is not necessary.