cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F105 unsigned division wrong result

JPasc.2
Associate II

Hello community,

  • Processor : STM32F105 (Cortex M3)
  • Compiler : GCC 6.3.1

I would like to execute the following assembly instruction :

udiv R3,R2,R3

where :

  • R2 = 64 000 000
  • R3 = 1

Instead of getting R3 = 64 000 000, I get R3 = 2047

I tried to execute strictly the same instruction in another part of the code and it works. I thought that the flash segment could be inconsistent but no other calculation is wrong in this part of the flash. I also tried to set manually the value of the memory where the PC points where this instruction is flashed and it works

I'm pretty sure that issue is hardware related because I have other STM32F105 which run the same code and the result of this division is correct.

Any idea on where the issue comes from ?

Thank you community

2 REPLIES 2

How is R1 involved?​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Sorry typing error. It should be R3 of course. I fixed it