Skip to main content
oeliks
Associate III
December 31, 2019
Solved

Avaraging unsigned integers

  • December 31, 2019
  • 9 replies
  • 1689 views

Hi, Im searching way to avarage two unsigned 32 integers.

Is there any hardware help in doing this with stm?

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    unsigned 32-bit, the assembler would allow for a two register add with carry output, then rotate right to recover the overflow carry, and then decide if you need the low-order bit dropping into the carry should round up, or not, basically an ADC with zero immediate.

    So 2 or 3 assembler instructions, all fast ones

    9 replies

    RMcCa
    Senior II
    January 1, 2020

    Smells like a homework assignment. Division by powers of 2 with unsigned math is super easy. ​

    oeliks
    oeliksAuthor
    Associate III
    January 1, 2020

    Man ... oh man =) Im not asking for software implementation but is there a hardware acceleration =) in stm32.

    IThink I read that some stm's support hardware ADC avaraging (addind next measurments and bit schifting).

    Its hobby, too old for homework :)​

    ​Im interested in stmf103 f303 h750 - playing with this micros :)

    S.Ma
    Principal
    January 1, 2020

    It already show that your question is not specific enough to get the anwer you look for.

    Averaging 2 numbers by hardware... the core is not?

    Well, at least look for FMAC CORDIC DFSDM peripiherals on the web to look for non core application specific accelerators.

    oeliks
    oeliksAuthor
    Associate III
    January 1, 2020

    Well Yes, question was not specyfic enough :) I ment without core.​

    Thanks :)​

    berendi
    Principal
    January 1, 2020

    The ADC averaging module is hardwired to average ADC values.

    DMA2D can average 8 bit values, like blending two bitmaps.

    DFSDM can do 16 bit averages, much like the one in the ADC, but it can take input data from DMA.

    Nothing I know of can do 32 bit averages outside the CPU core.

    oeliks
    oeliksAuthor
    Associate III
    January 1, 2020

    So I implemented it in software.

    But is it super easy? If it would be super easy there wouldnt be us patents solving this problem :) I think. ​

    berendi
    Principal
    January 1, 2020

    Entertaining a cat with the shiny dot of a laser pointer must be a quite complicated task then, because there are no less than 5 patents covering it.

    RMcCa
    Senior II
    January 1, 2020

    Cast them as floats and use the fpu?

    That's some hardware.​