This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to reduce crowd in the main file?

I want to ask a question.

The codes seem too complicated in main file. I created new sources and header files and carried some code into the new sources and header file from main file. For instance it was timer settings and timer handler function in the main files. I carried these into the new sources files.. But after that, my timers are didn't work correctly. For example, although the timers are stopped, they continue to run. however, such a problem did not occur when all the code was written in the main file. what is the reason of this? I want to reduce clutter in the main file. is not it possible?

Parents
  • Of course it's possible to take stuff out of the main.c file and move it into another - that's just standard 'C' refactoring.

    c-faq.com/.../decldef.html

    But, as with any other changes to existing code, you have to have a full understanding of what the existing code is doing and how it works before you start changing it.

    Did you get any compiler warnings?

    If your code doesn't work, then you need to look at how it was working before, and compare that to what your new code is actually doing.

    Step both versions in the debugger.

    Compare & contrast.

    k correctly. For example, although the timers are stopped, they continue to run.

    So you must have missed something in the stopping

  • My header and source files are as above. I include the file timer_init in main.c. but the timers don't stop when I stop them with app_timer_stop (). When the timeout expires, it stops itself.

    ***

    I will have one more question besides this topic. Suppose we define a timer for 20 second. When the timer is running (for example, at 15 seconds.) What if I restart the timer? Does the count value reset or keep counting?

  • Suppose we define a timer for 20 second. When the timer is running (for example, at 15 seconds.) What if I restart the timer?

    Isn't that stated in the app_timer documentation?

  • Are these questions related to the app_timer from the SDK, or is that something that you have implemented yourself in the timer_init.c/h files that you show in your screenshot?

    BR,
    Edvin

  • timer_init.h / c and main.c is also something I've implemented myself. More precisely, I received this project from someone else. I'm just trying to organize and understand the codes. I learned what nRF and BLE are just 3 weeks ago. I am a junior software developer. My English is not very good either. I do not fully understand which documents I should read. I would be glad if you could guide me as to which documents I should read.

    I also have one more question regarding flash memory usage in the forum. I expect your help in this matter too.
    Thank you.

Reply
  • timer_init.h / c and main.c is also something I've implemented myself. More precisely, I received this project from someone else. I'm just trying to organize and understand the codes. I learned what nRF and BLE are just 3 weeks ago. I am a junior software developer. My English is not very good either. I do not fully understand which documents I should read. I would be glad if you could guide me as to which documents I should read.

    I also have one more question regarding flash memory usage in the forum. I expect your help in this matter too.
    Thank you.

Children
Related