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.

Most instruction-efficient usage of ADCs and hardware multiplier

Other Parts Discussed in Thread: MSP430F5437A

I am using an MSP430 for a low-power maximum power-point tracking application (solar and TEG), and I need to measure current and voltage, and multiply them to get power.

What is the most instruction-efficient way of doing this, preferably in C, not assembly?

I read in the manual that the result of the hardware multiplier is available instantaneously, but I'm not sure if that means that the CPU automatically waits for the result, or if the result is actually available in less time than one clock period at the highest possible MCLK.

I was also thinking it might be possible to use the DMA to move the data from the ADCs to the hardware multiplier, so the CPU only had to wake up once all three values (current, voltage, power) were available.

The MSP430 can be any model. I currently have available the Launchpad+G2553 and ez430-F2013, but neither of these have the hardware multiplier, so I'll have to get something else anyway if the hardware multiplier is worth it.

I appreciate any input :)

  • Hello,

    i am working on some code which uses the hardware MPY, and I would say in time critical calculations or feedback loops it is definetly worth it.

    MSP430F5437A is my µC and in its datasheet and UserGuide you can read all the necessary times needed for certain calculations.

    For example and MPY with two 16 bit values would be available in around 7 MCLK cycles ( i didnt look it up but that should be the approximated time, maybe one mor eor less). and to move your ADC result into the MPY register I assume you can do this without DMA, of course in really time critical or LPM applications you have to, but as I never used this before I cannot say if or how that works.

    And of course your MPY doesnt know then the ADC result is finished converting, but your ADC knows, so you could simply poll the right flag until it is set, and then do the math.

    I hope this will help you out.

    Best wishes,

    Seb

  • Jacob Jorvang said:
    I'm not sure if that means that the CPU automatically waits for the result, or if the result is actually available in less time than one clock period at the highest possible MCLK.

    The MPY works on MCLK. So it is unimportant how fast MCLK is. There is a 16 and a 32 bit MPY. (and some MSPs don't have one at all). The timings are different.

    From the 1x family users guide (16 bit MPY):

    "The result is ready in three MCLK cycles and can be read with the next instruction after writing to OP2, except when using an indirect addressing mode to access the result. When using indirect addressing for the result, a NOP is required before the result is ready."

    The reason is that on direct addressign mode, the read instruction following the write of the second parameter requires one cycle for reading the instruction and one for the resutl register address, so teh result is fetched on the third cycle, where it is available. On indirect access, teh address in stored in a register, whcih does not need a cycle to be read. Then a NOP is required to make up for the missing cycle.

    On 32bit MPY, things are a bit more difficult. he four registers with the 64 bit result are fiilled at different times. However, the least significant word is availabel as fast as on the MPY16, so if you start readign the result there, the other registers are filled with the result when you approach them.

    There is a 'ready' interrupt, which can be used if you stuff the MPY wih DMA and fetch the results with DMA.

     

  • Thats just what I was looking for, thanks a lot :)

**Attention** This is a public forum