AnsweredAssumed Answered

USART polling vs Interrupt

Question asked by Nikhil Ingale on Aug 8, 2016
Latest reply on Aug 8, 2016 by Clive One
Hi,

I have implemented simple USART polling and interrupt method.
// main function
while(1)
     {
          
           send_data();
          //usartSendString(USART1,array,34);
          GPIOF->ODR ^= GPIO_Pin_10;

           
     }

///simple USART polling function
void usartSendString(USART_TypeDef *USARTx,uint8_t *data,int32_t length)
{
     while(length > 0)
     {          
          while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
          USART_SendData(USART1,data);
          data++;
          length--;
     }
}

When i send data using polling method, gpio high/low period is around 6ms and when i send it using interrupt method it's high/low period 150us.

send_data function sends the same number of bytes as sent in usartSendString() function .

why there is delay in polling method???

Outcomes