anton.bogdan

USART TX data is slowing IRQ handler execution

Discussion created by anton.bogdan on Dec 3, 2017
Latest reply on Dec 3, 2017 by anton.bogdan

Hello all,

 

i am working on a motor control application using a STM32F427,   where i use Timer2 as hall trigger for Timer1 who generates 6 pwm for the motor.

 

Beside this, every capture compare from Timer1 ( CC1,CC2,CC3)  is triggering ADC1,2,3  captures for current measurement

 

Til now so far so good, but if i want to send the information to a PC... then things are getting to be "slower".

 

For example i have 3 ADC handlers where i want to send adc data to the pc

 

 

char at[10]

 

void ADC_IRQHandler(void){

 

if(ADC_GetITStatus(ADC1,ADC_IT_EOC) != RESET) {
 

ADC_ClearITPendingBit(ADC1, ADC_IT_EOC); //Clear ADC1 JEOC pending interrupt bit

 

  GPIOA->BSRRL = GPIO_Pin_4; // set high
  adc_raw[1] = ADC_GetConversionValue(ADC1);
  sprintf(at,"%d",adc_raw[1]);
  USART_puts(USART3,"AW");
  USART_puts(USART3,at);
  USART_puts(USART3,"\r\n"); 
  GPIOA->BSRRH = GPIO_Pin_4; // set low
}

}

 

As it can be seen in the code above, i have introduce a PA4 pin to show me how long it takes to execute,  so with USART3 at 256000 baud rate it takes me arround 300 miliseconds 

 

300ms is huge since i am triggering adc at 25khz

 

Is there a way to send data faster or without interfering with the IRQ handlers processes?

Outcomes