Port toggling delay in MQX

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Port toggling delay in MQX

Jump to solution
687 Views
srikar
Contributor I

Hello all,

I am trying to toggle a port pin, using the code below, and I see using MQX on a 52259EVB takes a performance hit which I cannot explain.

 

Here is the test code I used in the scenario using MQX

 

      reg_ptr = _PSP_GET_IPSBAR();// Internal Peripheral Base Addr Reg

      gpio_ptr = &reg_ptr->GPIO;

 

      gpio_ptr->PORTAN   = 0x00  ;

      gpio_ptr->DDRAN    = 0xEE  ;  //  Select AN1 thru AN3 and AN5 thru AN7 as output pins

      gpio_ptr->PANPAR   = 0x11  ;  //  Assign AN0 and AN4 to A/D inputs, all others GPIO.

 

      while(1)   

      {

            gpio_ptr->PORTAN |= 0x04; 

            gpio_ptr->PORTAN &= ~0x04;

      }

 

And the test code in non MQX scenario

 

      PORTAN   = 0x00  ;

      DDRAN    = 0xEE  ;  //  Select AN1 thru AN3 and AN5 thru AN7 as output pins

      PANPAR   = 0x11  ;  //  Assign AN0 and AN4 to A/D inputs, all others GPIO.

 

      while(1)   

      {

            PORTAN |= 0x04; 

            PORTAN &= ~0x04;

      }

 

Both the test codes are trying to toggle the a port pin, the non MQX case taking around 500nsec to toggle a port pin, whereas an MQX test code takes around 2.5 usec.

 

I checked the core frequency for both, and they both are equal.

 

So is there something in MQX, which is causing this issue?

 

Srikar

0 Kudos
1 Solution
397 Views
JuroV
NXP Employee
NXP Employee

It depends on how you compile (optimize) the MQX code.

These codes are not equal. The MQX one stores IPSBAR and if the code is not optimized, then you compute the address of peripheral. The bare-metal assumes that the IPSBAR is constant, so it accesses direct memory, which (accidentally?) fits the correct register.

View solution in original post

0 Kudos
1 Reply
398 Views
JuroV
NXP Employee
NXP Employee

It depends on how you compile (optimize) the MQX code.

These codes are not equal. The MQX one stores IPSBAR and if the code is not optimized, then you compute the address of peripheral. The bare-metal assumes that the IPSBAR is constant, so it accesses direct memory, which (accidentally?) fits the correct register.

0 Kudos