cancel
Showing results for 
Search instead for 
Did you mean: 

number format multiply divide in STM32H757

vishalb1911
Visitor

Hi,

I am looking macro, in-bult function or lib to
1 - I can do 2 16-bit signed fraction number multiply or divide and result should also be in 16-bit signed fraction.
2 - define to convert any integer number (value less will be less than "1" to 16-bit) fraction number
6 REPLIES 6
vishalb1911
Visitor

we are working on real time data, so scaling is not working for us

 

TDK
Guru

> 1 - I can do 2 16-bit signed fraction number multiply or divide and result should also be in 16-bit signed fraction.

In the same instruction? There isn't an instruction for that. You could make your own macro but it wouldn't be particularly fast, which seems like the goal here.

If you feel a post has answered your question, please click "Accept as Solution".

Please suggest alternative for it, as in other mcu we get this type of functionality

KnarfB
Principal III

define to convert any integer number (value less will be less than "1" 

The only non-negative integer number less than 1 I know of, is 0.

 

Arm CMSIS-DSP is a library which supports a q15_t type calculations and conversions for 16-bit fraction numbers.

hth

KnarfB

> Arm CMSIS-DSP is a library which supports a q15_t type calculations and conversions for 16-bit fraction numbers.

Would have been my suggestion, too.

As a side note, this q<nn> datatypes are natively supported by almost all DSPs, usually in the single-instruction fashion the OP asks for.
Cortex M is not a platform otimized for realtime, high-throughput applications.

gbm
Lead III

For multiplication, (a * b) >> 16 should do. For division - go figure your school task by yourself. ;)

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice