Jump to content
Sign in to follow this  
basil4j

Floating and fixed point math capabilities

Recommended Posts

Hi All,

 

I'm new to the MSP430 and am looking at using some for a device I am developing. I will be using a handful of MSP430's on modular boards to perform various functions.

 

Some of the modular boards will be required to perform floating/fixed point multiplication and division.

I am trying to determine if I could get away with using an MSP device without hardware multiply to achieve these goals to keep the cost down.

 

Here are rough details of 2 of these boards (All FP and int are 16bits)

The calculations are in no particular order.

 

*Board 1, at 40 Hz, i.e. every 25ms

Receive 2x16bits from SPI sensor

Output 3x16bits serial onto external BUS (format to be defined)

Perform 2x FP/INT divide

Perform 1x FP/INT Multiply

Perform 2x FP/INT subtract

Perform 2x FP/FP divide

Perform 2x FP/FP Multiply

Perform about 6-8 FP =,> or < comparisons

 

*Board 2, at 400Hz, i.e. every 2.5ms

Receive 16 bits from SPI sensor

Output 2x16bits serial onto external BUS (format to be defined)

Perform 2x FP/INT divide

Perform 1x FP/INT Multiply

Perform 2x FP/INT subtract

Perform 2x FP/FP divide

Perform 4x FP/FP subtract

Perform about 8-10 FP =,> or

 

I think that's it. Do you think an MSP device at 16Mhz could handle this without hardware multiply?

Share this post


Link to post
Share on other sites

Small mathematics:

You have 16 million clock cycles per second.

And you have 25 ms time window.

One machine instruction takes 1 to 6 clock cycles (eg, on average pessimistic 4 cycles?)

 

In our time window processor executes (16e6 * 25e-3 / 4) = 100,000 machine instructions.

And your second example - 10,000 machine instructions in time window.

 

Your simple math is piece of cake for this brute force ...

 

Your problem is memory. FP math library consumes lot of flash space. IMHO 4kB flash is minimum, 8kB is better.

 

Install IAR workbench, write a simple test version of its mathematics and run in the simulator. Then change target versions (in simulator) and select processor that is best for your application.

Share this post


Link to post
Share on other sites

Thanks for the super quick reply!

 

That's what I thought, I am completly un familiar with this MCU so wasn't sure on how many cycles instructions take etc :)

 

Ill be using 8kb or 16kb devices if pos, so it looks as though ill be stuck with the CCS compiler. I assume the libraries are the same?

Share this post


Link to post
Share on other sites

Ill be using 8kb or 16kb devices if pos, so it looks as though ill be stuck with the CCS compiler. I assume the libraries are the same?

 

CCS don't have simulator (IMHO?). It's better first testing software and then buy adequate hardware. You don't need write full application, only time - critical part and exactly (in simulator) measure time and memory consumption. And then select adequate processor and buy it.

 

Libraries are not the same (calling conventions and source code in C is almost the same, but implementation in libraries is manufacturer-dependent). I don't know whether it is better this or that...

 

I personally hate Eclipse-based systems, then use IAR.

Share this post


Link to post
Share on other sites

Hi All,

 

Another semi related question :)

 

Each MSP will also need to output a constant 32kHz square wave for some sensors and also keep a few timers running to sync the communication windows for the bus output (I'm implementing a round robin type comms bus between devices) and various other things. These other timers only need 0.05ms accuracy or so, I've yet to sort out the details of these, may be stricter requirements, may be looser.

 

The device I'm looking at has 1 timer which I'm thinking would be best used for the constant 32kHZ output. Is it easy enough to code in software a couple of timers to take care of the comm window timing and a few other things? I've never used interrupts as I'm coming from the propeller MCU which doesn't have any, sorry if there is a simple solution to this!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...