first i want to thank you for your help. i haven't tried to prgramm the multiplication in asm, because i'm not used to programming asm. i only have tried to measure how long the µc takes for several operations and there i found that a multiplication of two 16 bit numbers takes a lot of time. i don't want to use asm code, because no one will be able to understand the code in a few months or years. thanks for your help nice greetings klaus
have you tried to perform such a computation by writing from your own the multiplication operation using ASM coding so avoiding the overload caused by the C compiler? Regards, Tanio
my st7fmc takes 31µs to multiplicate two 16bit variables. I'm using the metrowerks compiler. I know that it's difficult for the µC to handle 16bit variables, but this time is impossible for my application. can anyone tell me if this is right or do I have problems with compiler settings or something else. thanks a lot for your help best greetings klaus
welcome to the motor control forum dedicated to ST micro products. Your calculus seems correct, and effectively 15 us seconds are acceptable when multiply to 16 bits operands. Best regards, Tanio
sorry for my intrusion... what is the clock frequency you are using? If you use 8MHz, 122 cycles are equivalent to about 15usec... It's not too bad..., is it?
Posted on May 17, 2011 at 10:18Hi, low level routines such as integer multiply are wrtitten in assembler (by the compiler company) anyway. For example, here is what you get with Cosmic: ; INTEGER MULTIPLY ; Copyright (c) 1998 by COSMIC Software ; - 1st operand in X:A ; - 2nd operand in Y and extension ; xdef c_imul xref.b c_y .dcall ''3,0,c_imul'' ; c_imul: push a ; save LSB1 ld a,y ; load LSB2 mul x,a ; H * L ld c_y+1,a ; save in memory ld x,c_y ; load MSB2 pop a ; load LSB1 push a ; and save it mul x,a ; L * H add a,c_y+1 ; accumulate ld c_y+1,a ; and store pop a ; load LSB1 ld x,y ; load LSB2 mul x,a ; L * L push a ; save LSB ld a,x ; accumulate add a,c_y+1 ; MSB ld x,a ; in place pop a ; restore LSB result ret ; and return ; end this executes in 122 cycles, which, I guess, is consistent with the timing you measured (just multiply by the internal frequency you are using to check). Conclusion is, there seem to be no solution to your problem. Hope this helps. Regards, Luca PS: if you think multiplication is slow, don't even try the division...