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.

TMS570LC4357: Issues with the MCU transitioning from user mode to privileged mode

Part Number: TMS570LC4357

Hi, gundavarapu 

Previously, to allow the watchdog to reset the MCU, I entered privileged mode before the `while(1)` loop in the program.

image.png

The program runs normally when executed at address 0. However, when I moved the app to address 0x00080000, debugging revealed that this caused a prefetchEntry exception. What might be the cause of this?

  • Hi Shuo,

    Exactly at which instruction you are getting exception?

    And also, i got below suggestion from our internal AI for this issue, could you please verify this once?

    Looking at your code and the issue you're experiencing with the TMS570LC4357 microcontroller, I can identify a potential cause for the prefetchEntry exception when relocating your application.

    When you move your application from address 0x00000000 to 0x00080000, you're likely encountering an issue with the exception vector table location. The TMS570LC series MCUs expect the vector table to be at a specific location, and when you relocate your code, the processor might not be able to properly find exception handlers.

    The code snippet shows you're switching to supervisor/privileged mode using the u32ModeCpu register manipulation before entering your main while(1) loop. This works when your application starts at address 0, but causes problems when relocated.

    Possible solutions:

    1. Make sure you're properly configuring the Vector Table Offset Register (VTOR) when relocating your application. This register needs to be updated to point to your new vector table location.

    2. Check if your linker script correctly places all sections, particularly the vector table, at the appropriate offsets from your new base address.

    3. Verify that any memory protection unit (MPU) settings allow execution from your new code location.

    4. Ensure all exception handlers are properly initialized and relocated along with your main application code.

    5. Check if any absolute addressing is used in your code that might still be pointing to the original location.

    The TMS570 architecture requires careful handling of these relocation scenarios, particularly regarding exception handling and privileged mode operations.

    --
    Thanks & regards,
    Jagadish.