TC387 Divide by zero TRAP无法触发

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Wangbk
Level 3
Level 3
25 sign-ins 10 replies posted First question asked

Hi Infineon Support

        我在ADS的Blink LED程序中加了一行代码测试除以0进TRAP的情况:

        u8TestResult = 0xFFu / u8TestVal;

        测试发现当 u8TestVal = 0的时候,u8TestResult 结果为255,查找资料,发现了这个:

        AURIX™ MCU: FPUにゼロ除算例外のトラップを生成 – KBA234715 - Infineon Developer Community

        我在调试器上手动将 FZ 位使能,再进行测试,发现不起作用:

        (程序不会对这个寄存器做操作,先复位,再设置寄存器,再运行,还是不起作用)

        20231031140205.png

        请问这个寄存器对吗?有没有Demo代码可以参考一下?

BR

Wangbk

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Di_W
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 100 likes received
  1. Open the "CPU_Trap_Recognition_1_KIT_TC397_TFT" project in AURIX Development Studio.

  2. Locate and modify the "ifxCpu_Trap.c" file in the project. Make the necessary code changes to meet your requirements.

  3. After making the modifications, save the changes to "ifxCpu_Trap.c."

  4. Build the project to compile the modified code.

  5. Debug the project on the Triboard. Connect your target hardware and initiate the debugging session.

  6. Run the project on the Triboard. Ensure that the code is executing on the target hardware.

  7. During the execution, a trap will occur in the "IfxCpu_Trap_assertion" function.

  8. To inspect the trap, check the "trapWatch" variables in the Variables window of the AURIX Development Studio.

  9. In the Variables window, you will find the following trap-related information:

    • "tAddr" (trap address)
    • "tID" (trap ID)
    • "tClass" (trap class)
    • "tCpu" (trap CPU)

dw_0-1698809864087.png

 

  1. https://github.com/Infineon/AURIX_code_examples/tree/master/code_examples/CPU_Trap_Recognition_1_KIT...
  2. https://www.infineon.com/aurix-expert-training/Infineon-AURIX_CPU_Trap_Recognition_1_KIT_TC397_TFT-T...

 

View solution in original post

0 Likes
2 Replies
Di_W
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 100 likes received

如果是整数,你可以看一下PSW寄存器的高8位。AURIX处理器的PSW(程序状态字)寄存器包含了多个位,其中一些位与ALU(算术逻辑单元)操作相关。

 

dw_0-1698746094508.png

 

0 Likes
lock attach
Attachments are accessible only for community members.
Di_W
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 100 likes received
  1. Open the "CPU_Trap_Recognition_1_KIT_TC397_TFT" project in AURIX Development Studio.

  2. Locate and modify the "ifxCpu_Trap.c" file in the project. Make the necessary code changes to meet your requirements.

  3. After making the modifications, save the changes to "ifxCpu_Trap.c."

  4. Build the project to compile the modified code.

  5. Debug the project on the Triboard. Connect your target hardware and initiate the debugging session.

  6. Run the project on the Triboard. Ensure that the code is executing on the target hardware.

  7. During the execution, a trap will occur in the "IfxCpu_Trap_assertion" function.

  8. To inspect the trap, check the "trapWatch" variables in the Variables window of the AURIX Development Studio.

  9. In the Variables window, you will find the following trap-related information:

    • "tAddr" (trap address)
    • "tID" (trap ID)
    • "tClass" (trap class)
    • "tCpu" (trap CPU)

dw_0-1698809864087.png

 

  1. https://github.com/Infineon/AURIX_code_examples/tree/master/code_examples/CPU_Trap_Recognition_1_KIT...
  2. https://www.infineon.com/aurix-expert-training/Infineon-AURIX_CPU_Trap_Recognition_1_KIT_TC397_TFT-T...

 

0 Likes