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.

ARM mode of the TMS570LS0332 using SafeTI library

Other Parts Discussed in Thread: TMS570LS0332, HALCOGEN

Hi,

I have ported the safeTI Library demo application provided for TMS570LS04X to TMS570LS0332 micro controller. I have notice that, micro controller is in SVC mode by the time it reaches the main() in the software.  I found that SL_Init_R4Registers() function is the reason for that. The function keeps the micro controller in SVC mode at the end. Is this expected?

When i checked the _coreInitRegisters_() function, which is generated by HALCoGen, the micro controller mode is put to SYS mode before it leaves the function. 

Is it necessary for the micro controller to be in SVC mode , when we are using the SafeTI library? if so, i should change the stack size of SVC mode to fit my application stack as well. 

Thanks in advance.

Best Regards,

Sreekanth challa 

  • Sreekanth,

    Really this isn't a safety library question. The device resets into SVC mode and I am not sure why the Safety Library leaves you in this mode but it may be just an issue w. the demo.

    When you integrate this library into your application - if you are going to go through the trouble of the safety library then I am sure you will also want to make use of the memory protection unit and capabilities of the device.

    This means that you should be using USER mode for most of your application tasks and SYSTEM mode when the task needs privilige [ex. is a device driver] and you should set the MPU up for each task to limit it's access to the memory that it needs and not the memory of other unrelated tasks. You can look at the FreeRTOS OS as an example of how this is implemented on the device.

    USER and SYSTEM modes are the same basically [in terms of register banking, stack pointer, etc] but SYSTEM just runs w. privilege.

    SVC mode is the mode after reset, but normally you don't want to run code in SVC mode because the SVC (or SWI) instruction is how you can get privilege back only when needed ... [kind of like 'sudo' in unix.. ] and if you use this instruction from inside SVC mode it will corrupt its LR so you normally don't run in SVC mode except immediately after the SVC or SWI instruciton.

    This is really 'ARM' architecture stuff rather than anything device or software specific so you might look at various appnotes and or programmers guides for the ARM architecture to understand this better.

    -Anthony
  • Hi Anthony,

    Thanks for the prompt and detailed response. I understand the ARM modes and their usage. I would like to know the following.

    1. Is it necessary to keep controller to be SVC mode in order to self test on power sequence?

    2.In the SafeTI demo application, was controller intentionally left in SVC mode?  I do not understand the reason? 

    3.  The following APIs of Safety Library exit in  SVC mode as per Safe TI User guide. Is there any function available to change the ARM to SYS mode?

    • SL_SelfTest_EFuse()
    • SL_SelfTest_Status_EFuse()
    • SL_SelfTest_Status_STC()
    • SL_Init_R4Registers()
    • SL_Init_StackPointers()
    • SL_SelfTest_CCMR4F()

    Thanks& Best regards,

    Sreekanth Challa

  • The User's guide lists entry and exit modes for the various functions.

    See below for some examples. SVC is only specifically called out as the exit mode for two functions..

    (search SVC in the user's guide)

  • Hi Anthony,

    Thanks for the response. I have done the same when i mentioned list of SafeTI API exit in the SVC mode.

    There are 6 functions (SafeTI APIs) which exit in SVC mode. I am trying to run my application in SYS mode (Same as user mode with Privilege ). I want o change the mode of the ARM to SYS mode before starting the application. Is there any API available to do that?


    Thanks in advance.
    Best Regards,
    Sreekanth Challa
  • I don't see an API in HalCoGen for this. But you can look at sys_core.asm to see how it is done when registers are initialized.