cancel
Showing results for 
Search instead for 
Did you mean: 

Time diference betwen using ST libraries and uControler registers directly

tecnico23
Associate II
Posted on March 13, 2014 at 11:55

Hi

I'm using STLibraries for programing a STM32F100 in crossStudio. I have my System Clock with 24MHz.

When I set and reset a port pin, using LT Libraries

while(1){

  GPIO_SetBits(DISP_DIGIT1_PORT, DISP_DIGIT1_PIN);

  GPIO_ResetBits(DISP_DIGIT1_PORT,DISP_DIGIT1_PIN);

}

 since the moment of set to the moment of reset the uController spend, more or less, 2.26us (442KHz). On the other hand, if I do the same using the uController register

 

while(1){

  DISP_DIGIT1_PORT->BSRR = DISP_DIGIT1_PIN;

  DISP_DIGIT1_PORT->BRR = DISP_DIGIT1_PIN;  

 }

the this time is only 164ns (6.1MHz).

So, my questions are : This diferences on time is normal? There are any solucion for using LTLibraries and reduce this time?

Best Regards

A Paiva   

1 REPLY 1
Posted on March 13, 2014 at 12:07

> This diferences on time is normal?

Look at the generated assembler. The first one probably results in function calls, the second is probably inlined as one or few instructions.

> There are any solucion for using LTLibraries and reduce this time?

Switch on optimizations.

JW