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

sdk_config overwritten by sdk_old_config

hello nordic

i have been working with nrff52832 with the SDK16.0 (also working with s132 if it matters)

it is a real head braking to deal with your never ending sdk_config.h, today i found out that he has an even more evil origen which is the sdk_old_config.h 

why do we need 2 files defining the same things, seems like a very poor solution to whatever problem 

i wish to configure a timer by enabling NRFX_TIMER_ENABLE so i change it in the sdk_config.h but it does nothing, i have tried to disable every definition that seems related to legacy but still nothing changes 

please help it been to many hours of try and error with no real programing because of that

best regards and hope for better days

Ziv

Parents
  • Hello Ziv,

    please help it been to many hours of try and error with no real programing because of that

    I am sorry to hear about the troubles you have had with this!

    it is a real head braking to deal with your never ending sdk_config.h, today i found out that he has an even more evil origen which is the sdk_old_config.h 

    why do we need 2 files defining the same things, seems like a very poor solution to whatever problem


    I can understand how the overwrite performed by apply_old_config might seem backwards - but it is done to provide backwards compatibility for customers with projects using legacy drivers.

    In essence, to avoid having the apply_old_config overwrite your sdk_config you will have to remove all legacy driver *_ENABLED defines from your sdk_config. To be absolutely clear: you may not leave the legacy *_ENABLED set to 0, that will still leave them defined and cause the override by apply_old_config. So, to avoid this either comment out or remove entirely the legacy driver *_ENABLED defines.
    In your case, that means that you can only have NRFX_TIMER_ENABLED defined in your sdk_config - as long as the legacy *_ENABLED is defined it will overwrite the NRFX_*_ENABLED.

    For more information about this, please see the discussions in this and this ticket.

    Please let me know if anything still should be unclear.

    Best regards,
    Karl

  • i have tried to disable all legacy related defines but actualy there is

    // <e> TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer
    //==========================================================
    #ifndef TIMER_ENABLED
    #define TIMER_ENABLED 1
    #endif

    in the sdk_config.h and it must be set to 1 , and also i may beed other drivers like uart, twi and such 

    BUT, it seems that if i only enable the TIMER_ENABLE and leave the NRFX_TIMER_ENABLED 0,  then it seems fine.. i think .. not sure because it creates another issue .. the nrfx_timer.c  driver does not have any dependencis for some reason .. and if i disable TIMER_ENABLE back to 0 then the dependencies return .. WTF (sorry for that but it has been half a day already and no progress in the simplest thing of adding a timer to a project)

    but i get this error in the ntfx_timer.c file

    #error "No enabled TIMER instances. Check <nrfx_config.h>."

    and last try so far ...

    if i set the TIMER_ENABLE TO 0

    and in the nrfx_timer.h file i add the definition of NRFX_TIMER0_ENABLE 1

    #define NRFX_TIMER0_ENABLED 1 // ziv addition
    #ifndef __NRFX_DOXYGEN__
    enum {
    #if NRFX_CHECK(NRFX_TIMER0_ENABLED)
        NRFX_TIMER0_INST_IDX,
    #endif
    #if NRFX_CHECK(NRFX_TIMER1_ENABLED)
        NRFX_TIMER1_INST_IDX,
    #endif

    then i get a warning of redefinition, but if i don't write it there then it is not defined at all .. again sorry but WTF ?

    any ideas ?

  • i have also tried to use 

    nrf_drv_rtc_t

    same issue just with the rtc parameters 

    you should add emojis to this chat so i can try to pass my sad tired face .. struggling with the simplest thing for a whole day 

  • Hello Ziv,

    ziv123 said:
    you should add emojis to this chat so i can try to pass my sad tired face .. struggling with the simplest thing for a whole day 

    I am sorry to hear that!
    Are you doing this by using the TIMER peripheral directly?
    In the case that you are interested in using the RTC, the easiest way you can add a timer to your project would be to use the app_timer from the timer library rather than using the TIMER peripheral directly.

    ziv123 said:
    i have tried to disable all legacy

    Given the importance of the distinction between disabled ( *_ENABLED 0 ) and removed, could you verify for me what you are doing in the code when you are 'disabling' the legacy related defines? I think you have got it correctly, but I am asking just in case. 

    ziv123 said:
    in the sdk_config.h and it must be set to 1 , and also i may beed other drivers like uart, twi and such 

    For future reference, you might find the Migration to nrfx Guide useful to have a look at when migrating code from nrf_drv drivers to the nrfx_ drivers.

    ziv123 said:
    and in the nrfx_timer.h file i add the definition of NRFX_TIMER0_ENABLE 1

    I would advise against spreading your peripheral configuration defines out into the different driver source / header files.
    You should instead keep all the defines in the sdk_config or alternatively the app_config (for application-specific configurations).

    Also, you should keep in mind that TIMER0 is used for the SoftDevice - this is probably the cause of the issue you detail in your previous comment.

    ziv123 said:
    then i get a warning of redefinition, but if i don't write it there then it is not defined at all .. again sorry but WTF ?

    Could you tell me, is it an example you are trying to add the nrfx_timer to? If so, which example are you working with?

    Best regards,
    Karl

  • Hi Karl

    would be to use the app_timer

    the app timer works with the low frequency clock if i am correct. .. i need faster frequency of pin toggle (i was actually starting to do it with pwm, since the timer just took to much time so far, but i am not sure it will be accurate cause i read that it sometimes not with ble scanning at the same time, also it is much more complex to redefine the top counter and/ or frequency each time to get the change in period and maintain 50% duty cycle all the time as well) 

    Given the importance of the distinction between disabled ( *_ENABLED 0 ) and removed, could you verify for me what you are doing in the code when you are 'disabling' the legacy related defines? I think you have got it correctly, but I am asking just in case.

    i am just trying to set an instance:

    //static nrf_drv_timer_t move_timer = NRF_DRV_TIMER_INSTANCE(0)

    and i can remove or disable but i do need some of this drivers enabled i guess so ...

    I would advise against spreading your peripheral configuration defines out into the different driver source / header files.

    off course its bad practice and i don't tend to do that it was more for testing and trying to understand something maybe but i do not keep it changed.

    Also, you should keep in mind that TIMER0 is used for the SoftDevice - this is probably the cause of the issue you detail in your previous comment

    if i define NRFX_TIMER1_ENABLE i get the same issue of redefinition .. so i guess i didn't understand that 

    best regards

    Ziv

  • Hello Ziv,

    Karl Ylvisaker said:
    Could you tell me, is it an example you are trying to add the nrfx_timer to? If so, which example are you working with?

    Please clarify on this question.

    ziv123 said:
    the app timer works with the low frequency clock if i am correct. .. i need faster frequency of pin toggle (i was actually starting to do it with pwm, since the timer just took to much time so far, but i am not sure it will be accurate cause i read that it sometimes not with ble scanning at the same time, also it is much more complex to redefine the top counter and/ or frequency each time to get the change in period and maintain 50% duty cycle all the time as well) 

    You are correct - I suggested the app_timer since you mentioned that you were attempting to use the RTC.
    Which frequency will you be working with, and which timer instance ID do you have available for this?

    ziv123 said:
    off course its bad practice and i don't tend to do that it was more for testing and trying to understand something maybe but i do not keep it changed.

    I understand, that is good to hear. I just mentioned it to make sure.

    ziv123 said:
    if i define NRFX_TIMER1_ENABLE i get the same issue of redefinition .. so i guess i didn't understand that 

    Would you mind sharing the contents of your sdk_config and the error that is generated during the compilation?
    I can convert the ticket to private view if you would not like to share the code publicly.

    Best regards,
    Karl

  • hi Karl

    Please clarify on this question.

    its a code i was working on with the other project i just minimized it, the basic was the central app_ble_blinky example, to that in the other project i added the app timer, pwm, twi, uart, saadc and i think that's it . but i don't need all of that in the current project just ble scanning and a timer for pin toggling, later there will be more things like twi i think, some communication for sure.

    you mentioned that you were attempting to use the RTC.

    i thought that RTC can be configured to HF, but i rechecked the data sheet - off course you are correct

    Would you mind sharing the contents of your sdk_config

    you want the whole 12030 lines of sdk_config lines here? i am guessing i didn't understand your meaning, but the sdk_config is just defines it does not revile anything on my project to my understanding so i don't mind sharing if i understood better what to share 

    best regards

    Ziv

Reply
  • hi Karl

    Please clarify on this question.

    its a code i was working on with the other project i just minimized it, the basic was the central app_ble_blinky example, to that in the other project i added the app timer, pwm, twi, uart, saadc and i think that's it . but i don't need all of that in the current project just ble scanning and a timer for pin toggling, later there will be more things like twi i think, some communication for sure.

    you mentioned that you were attempting to use the RTC.

    i thought that RTC can be configured to HF, but i rechecked the data sheet - off course you are correct

    Would you mind sharing the contents of your sdk_config

    you want the whole 12030 lines of sdk_config lines here? i am guessing i didn't understand your meaning, but the sdk_config is just defines it does not revile anything on my project to my understanding so i don't mind sharing if i understood better what to share 

    best regards

    Ziv

Children
  • Hi Ziv,

    ziv123 said:
    its a code i was working on with the other project i just minimized it, the basic was the central app_ble_blinky example, to that in the other project i added the app timer, pwm, twi, uart, saadc and i think that's it . but i don't need all of that in the current project just ble scanning and a timer for pin toggling, later there will be more things like twi i think, some communication for sure.

    Adding a timed pin toggle to the central BLE blinky project, understood. At what frequency will this pin need to toggle? - and what is the use-case you have in mind?
    As detailed in the migration to nrfx guide I referenced in my previous comment most of the nrfx communication drivers are "straight forward" to add to your project - should you encounter any issues with this please let me know.

    ziv123 said:
    you want the whole 12030 lines of sdk_config lines here? i am guessing i didn't understand your meaning, but the sdk_config is just defines it does not revile anything on my project to my understanding so i don't mind sharing if i understood better what to share 

    If you are going to share the sdk_config please upload it using the "Insert->Insert file" option here on DevZone - do not copy its contents directly into the reply.
    Seeing the entire file will make it easier to understand what you are referencing in your previous replies.

    I can make the ticket private at any time in the future, if you should feel that it needs to be viewable by only us here at Nordic and you yourself. Just let me know if you would like me to make this change.

    Best regards,
    Karl

  • 0207.sdk_config.h

    also, since i have started with the pwm now .. is it an ok approach working with pwm, .. just to have something working and then go again on the timer if there is time? 

  • Hello again Ziv,

    Looking at the sdk_config you have provided I see that you have not made the changes that I mentioned to the TIMER_ENABLED legacy define.
    In the sdk_config you provided TIMER_ENABLED is still defined, but with the value 0.
    You will need to remove it completely, either commenting it out or removing it from the file all together.

    Furthermore, you must enable NRFX_TIMER_ENABLED by setting it to 1, along with one of the timer instances.
    You may also remove the APP_TIMER_ENABLED, since you do not want to use the app_timer library.

    ziv123 said:
    also, since i have started with the pwm now .. is it an ok approach working with pwm, ..

    Since I do not know the use-case for your application or what you intend to make this application do its hard for me to tell you that it is an ok approach.
    In the case that you want to toggle the pin just to control the brightness of a LED or servo motor then I would certainly recommend the PWM library, but if you are trying to bit-bang then I would recommend against it. All I currently know about the application is that you want to toggle a pin at a frequency higher than the RTC - which does not tell me much about what the pin will end up being used for.

    Best regards,
    Karl

  • hi Karl

    Looking at the sdk_config you have provided I

    ok , i did as you explained , removing and not just enable set to '0', and compilation went ok .. so that was great and thanks A LOT for that. i will need that experience in the future for sure. however, at the moment there is a change in stepper motor so it seems for now that the app_timer will do just fine after all. sorry for all the fuss over nothing but like i said it is a good experience for me because for sure i will need that someday. 

    so i also gave up the pwm :) 

    right now i am moving to build a code that transmit ble beacon / no connection advertising

    if you can recommend a good ble example to start from that will be great .. i will need to receive data via uart or twi and transmit it via ble to several units with identical code (each will have its own id)

    i am thinking of starting from 'ble_peripheral -> ble_app_beacon example .. though it seems that it is advertising a fixed message and i need to be able to change the data in the message according to data from uart.. anyway, if i struggle with that to much i will open another thread 

    thanks a lot for this one 

    i mark it answered for now Slight smile

    best regards

    Ziv

  • Hello Ziv,

    ok , i did as you explained , removing and not just enable set to '0', and compilation went ok ..

    I am glad to hear that it resolved your issue. It is a common mistake to leave the unused legacy _ENABLED defined to 0, so it is definitely something to look out for in the future as well.

    that was great and thanks A LOT for that

    No problem at all, Ziv.
    I am glad you found my replies useful!

    however, at the moment there is a change in stepper motor

    Up until now you have never told me that this was in order to control a stepper motor. Now that I know, I would definitely recommend that you use the app_pwm library to control it instead.

    so i also gave up the pwm :) 

    The PWM Library usage (app_pwm) is demonstrated in the PWM Library example, and the PWM Peripheral is demonstrated in the PWM driver example, I would recommend that you take a look at those if you need to generate a PWM waveform.

    right now i am moving to build a code that transmit ble beacon / no connection advertising

    if you can recommend a good ble example to start from that will be great .. i will need to receive data via uart or twi and transmit it via ble to several units with identical code (each will have its own id)



    Just to be clear, you would like to create a beacon ( non-connectable ) that will broadcast data it receives over UART?
    In that case, I would suggest that you begin with the BLE peripheral beacon example and then merge inn the UART functionality from the peripheral UART example to receive data over UART.
    Then you will need to modify the beacon to update its manufacturer specific data, to contain the received UART data.

    Keep in mind that you will need two advdata_t instances which you alternate between advertising and updating, if you intend to use the advdata_update function from the advertising library.

    i am thinking of starting from 'ble_peripheral -> ble_app_beacon example .. though it seems that it is advertising a fixed message and i need to be able to change the data in the message according to data from uart.. anyway, if i struggle with that to much i will open another thread 

    Yes, this is exactly what you need to do. Sorry, I wrote the above suggestion before reading this part of your reply, my bad.
    Please open a new ticket if you should encounter any issues or questions.

    Good luck with your development!

    Best regards,
    Karl

Related