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: Is it possible to write C handler for the exceptions (Data Abort, Prefetch Abort and Undef Entry)

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Hi All,

Based on the halcogen gen files, I looked into HL_sys_intvecs.asm

resetEntry b _c_int00
undefEntry b undefEntry
svcEntry b svcEntry
prefetchEntry b prefetchEntry
dataEntry b dataEntry
b phantomInterrupt
ldr pc,[pc,#-0x1b0]
ldr pc,[pc,#-0x1b0]

Can I start to write the c handler here to perform some of the house keeping tasks when exceptions taken place? Is there any TI #pragma to required or support to do so, with minimum or no assembly code.

Thanks, and look forward hearing from TI experts and community members. 

  • Hi Deric,

    You can customize and write your own data abort handler if required. Not for just data abort even for any abort if needed.

    Usually if a data abort occurs then it will branch to the same abort instruction, like as shown in below

    Here you can modify to branch to the required routine:

    You can just import the routine and just branch to the corresponding routine if exception occur.

    Now in that definition of the routine, you can just write the required operation:

    Like above, here i am just resetting the device.

    I am providing one example project for your testing purpose

    In this example, i am just toggling two GPIO's (they are connected to LED's in Launchpad), and after toggling them for 10 times, then i am just creating data abort by directly writing to the flash instead of using FAPI library.

    So, this creates data exception, and the processor will execute the code in the user_dataEntry_exception_handler, so the processor will get reset and repeat the same process.

    I tested at my end, please take it as reference.

    Writing_C_Handler_For_Exception_LC4357.zip

    --

    Thanks & regards,
    Jagadish.

  • Hi Jaga

    Thanks a lot, that is fast way to create the abort. The code run well until the return from the handler. I wanted to return to the main and continue with the blinking, but when i commented off the line in the exception_handler. Using the debugger, it is always looping there. I suspect that the return address in LR need to be modified to compensate the offset.

    // systemREG1->SYSECR  |=   (1 << 15);  /*Software Reset*/

  • Hi Deric,

    In that case you have to call the main function in the handler.

    Without calling the main function how can it again execute the main function, so just call the main function in handler again for to continue the operation.

    --

    Thanks & regards,
    Jagadish.

  • Hi Jaga

    I have found the answer in the TI compiler manual spnu151W dated in Mar2023 on page 106. 5.11.16 The INTERRUPT Pragma. Using this method, I can continue the execution in main.