UART interrupt routine

hi guys,

can i have some help regarding the given code below.

in the code i am capable of using the interrupt based receiving.

but i have to tell how much byte i m sending.

Now i wish whenever the data come it should go to IRQ handler

void UART0_IRQHandler(void)
{
  if(UART_GetITStatus(UART0, UART_IT_Receive) != RESET)
  {
        RxBuffer[RxCounter++] = UART0->DR;
        RxBuffer[RxCounter++] = UART0->DR;
        RxCounter==rxNum +2;
        if(rxNum == 0)
        {
         rxNum = (RxBuffer[0] * 256) + RxBuffer[1];
         while((RxCounter - 2) != rxNum)
         {
          test_num++;
          if((UART_GetFlagStatus(UART0, UART_FLAG_RxFIFOEmpty) != SET)&&(RxCounter < RxBufferSize))
            {
              RxBuffer[RxCounter++] = UART0->DR;
            }
          }
          rxNum = 0;
          test_num = 0;
        }
    }
}


Parents
  • 1) You forgot to mention what processor you have.

    2) Why do you think you can pick up more than one byte from the FIFO without first checking if there are more than one character in the FIFO? You normally check for receive fifo non-empty and as long as that condition you can pick up one more character.

    Here, you pick up two characters - why?

            RxBuffer[RxCounter++] = UART0->DR;
            RxBuffer[RxCounter++] = UART0->DR;
    

Reply
  • 1) You forgot to mention what processor you have.

    2) Why do you think you can pick up more than one byte from the FIFO without first checking if there are more than one character in the FIFO? You normally check for receive fifo non-empty and as long as that condition you can pick up one more character.

    Here, you pick up two characters - why?

            RxBuffer[RxCounter++] = UART0->DR;
            RxBuffer[RxCounter++] = UART0->DR;
    

Children
More questions in this forum