This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Embedded C Coding guide?

I have currently joined a new company as a Embedded Engineer. And I am feeling that my role is working on Firmware. But the management expects me to write new firmware for new products which I have not done till date, i.e., firmware implementation rom scratch. Can Any one help me in this situation? I have keen interest in Embedded and loving their expectation from me, but at same time I am not sure how to achieve the goal in a pre determined time period.  So, If any one can suggest me some good resources for firmware implementation it will of great help.

  • Hi Sanket,

    1. You can start it from looking into K&R Book, the developers of C programming.
    2. You can refer to this book: www.pearsonhighered.com/.../PGM124303.html
    3. You can read and follow MISRA C coding guidelines.
    4. There is no better resource than the code itself. You can refer to sample codes and example codes that come along with embedded hardware; Linux code for embedded systems; RTOSes like freeRTOS, which run in very lower memory foot print.

  • Thank you for the suggestions and help. I will definetely use the book and mentioned points.
  • I have read Misra rules but still I am not understanding the code written for taximeters to that level of clarity and no one in my organisation is explaining the code in detail. How to overcome this issue. For Eg.: GPS and GSM Initialisation process. GPS Module is L80 of Quectel and GSM M95 Quectel. the process of initialisation written in code is difficult from my point of view. I read datasheet but still I am stuck?
  • Hi Sanket,

    Understand the interface to the GSM/GPS module. Get the whole picture of how it is connected to the embedded Board. Start from block diagram in mind. Then go module by module.

    Don't club code and datasheet together. When reading datasheet try to understand rather than worry about how you need to code or where in code it is done. Separate understanding and coding. Write down diagrams and points about your understanding of the module. Read more about it(starting from wikipedia) and cross verify your understanding.

    Coding is just one aspect and the least one.

    Nobody helps us when we are in office, unlike school or college. When people with whom you work cannot, definitely not outsiders like me. Stay calm and not worry about deadlines. Understand like you need to learn a module and then finally look into code. Study phase is a very important part of coding! If code goes wrong, you will get build error. But if your understanding goes wrong, no point having a well written code, since the other end of hardware won't respond.
  • I am writing code for IBM Bluemix and AWS iot in Embedded C. The code will switch between these two platforms depending on user. The user can configure the parameter of both Platform. MQTT 3.1.1 with JSON is used.

            I want to write the code efficiently that is I want to keep  the parameters of connect, subscribe, publish, user configurable parameters in structures which will update the parameters accordingly. Also, instead of malloc I want to use circular buffer.

            I am a average coder, so if I get a good resource or case studies of Embedded C based products, it will really help me to write efficient code.

          Can you refer me a book on practical implementation of Embedded C for Code efficiency or any other resource? 

  • Hi Sanket,

    There will not be one stop solution for the exact requirement. As I told before, check the other piece of code in Embedded Board that you are running. Check sample codes.
    Remember, the most important constraint in Embedded world is resource(memory), when it comes to programming. Keep that in mind and continue. Like every hurdle you cross like say malloc, check alternative, understand and implement it.
  • Thank you for your reply. Where are this sample code available?? is it on github??
  • I have no idea of which Board you are working, to comment on its sample code.
  • We have our inhouse board with NXP Kinetis series K20 and Quectel 95 GSM Module.
  • I have not used NXP kinetis and its code. But there is code and tools here. Check each one if there are code : www.nxp.com/.../kinetis-software-and-tools:KINETIS_SWTOOLS