Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

compiler optimization level nrf api going wrong

sdk 17.0.2

IDE - segger embedded studio 

For the below given code, "pin" is not updating when GPIO goes high when optimization level is kept  "Level 3 for more speed". upto "level 2" , "pin" is updating properly.

Could you please let me know why the update is not happening for Level3 optimization ? I added "volatile" qualifier for variable "pin", but still not working

bool pin;

nrf_gpio_cfg_watcher(PIN12);

pin= nrf_gpio_pin_read(PIN12);

Parents Reply
  • Hi,

     

    kizhimon said:
    1) But why this problem is not happening when optimization level is low (the peripheral still runs at 16M).

    its because no optimization uses more cycles in between configuring and reading the gpio input. 

     

    kizhimon said:
    2) don't you think these corrections should be included in the SDK driver files?

    There are not many cases where this issue of synchronization occurs, as a wait state is introduced whenever you read a event register. Adding a wait-state on all calls will not be efficient.

     

    Kind regards,

    Håkon

Children
Related