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.

Pass reset reason to main()

Other Parts Discussed in Thread: TMS570LS1224, HALCOGEN

Hello,

Is is possible to read MCU reset reason during operation inside main()?

I am using SDL and SL_Init_ResetReason(). Inside this function SYSESR is being cleared. Off course I can read value of this register before calling SL_Init_ResetReason(). But how can this value be passed to main()?
I am conscious that I can use type=NOINIT for some data but unfortunately, this solution works only after SL_Init_Memory(RAMTYPE_RAM) is being called.

Is there any solution to keep any data recorded before executing SL_Init_Memory(RAMTYPE_RAM)?

  • Hello Michal,

     Please provide what MCU you are using.  

    Thank you,

    ~Leonard  

  • Hello,
    I am using TMS570LS1224.

  • Could you please answer my question? Or maybe you know somebody who can help?

  • Hello Michal,

    I cannot answer your question but I have located someone in this product group who can.  Apologies for the delay. 

    Regards,

    ~Leonard 

  • The start-up sequence generated by HALCoGen is what is typically followed. You can modify this sequence as required to fit your application. You can delay the read of the reset reason until main() if you would like. Another option is to explore the keyword "register" which requests the compiler to store the variable in a CPU register. Note that the compiler could ignore this request as well, depending on how many "register" requests are made. Also, only a local variable can be stored in a register, so this value cannot be directly accessed from outside the function in which it is declared.

    You can also define a global variable to store the reset reason (read value from 0xFFFFFFE4 and assign to this variable). In this case, you need to take care and initialize the CPU RAM before you read the reset reason, as any read access to uninitialized RAM can cause an ECC error if ECC checking is enabled.

    In summary, the sequence for the application to manage the reset reason, the required system initialization, checking the safety diagnostics etc. is entirely up to the application designer. The start-up sequence generated by HALCoGen is a typical sequence that works for most applications.

    Hope this helps.