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 :)
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.
Jacob Jorvang 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.
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.
Time to say goodbye - I don't have the time anymore to read and answer forum posts. After falling behind by two months (900 threads), there's no point in continuing. See my bio for details.Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.
In reply to Jens-Michael Gross:
Thats just what I was looking for, thanks a lot :)
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.