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.

Compiler/TDA2EXEVM: Regarding Exception Handler in MPU A15

Part Number: TDA2EXEVM

Tool/software: TI C/C++ Compiler

Hi,

 We are trying to generate Undefined Instruction exception on a divide-by-zero. 

Following are the steps doing for that.

volatile uint16 GucNullcheck = 10;

 volatile uint16 LucZeroDivisor = 0;

1> SET the SCTLR 19 bit DZ

     VAR(uint32, OS_VAR_CLEARED) LddCurrentTick=0;
     ASM volatile("MRC p15, 0, %Q0, C1, C0, 0" : "=r" (LddCurrentTick));/* cntpct */
     LddCurrentTick = LddCurrentTick| 0x80000;
     ASM volatile("MCR p15, 0, %0, c1, c0, 0" : : "r" (LddCurrentTick));

2> GucNullcheck = GucNullcheck/LucZeroDivisor;

As per doc it say that it generate the exception on SDIV and UDIV instruction but it should not generate after the execution of second instruction

Following are the assembly code for reference

161 GucNullcheck = GucNullcheck/LucZeroDivisor;
403057d0: F645432C movw r3, #0x5c2c
403057d4: F2C40330 movt r3, #0x4030
403057d8: 881B ldrh r3, [r3]
403057da: B29A uxth r2, r3
403057dc: 887B ldrh r3, [r7, #2]
403057de: B29B uxth r3, r3
403057e0: FBB2F3F3 udiv r3, r2, r3
403057e4: B29A uxth r2, r3
403057e6: F645432C movw r3, #0x5c2c
403057ea: F2C40330 movt r3, #0x4030
403057ee: 801A strh r2, [r3]

Please suggest the missed Scenario that generate Undefined Exception.

Thanks,

Harshalkumar Shinde