Math Functions

Discussions on how to get your MSP JTAG programmer up and running.

Moderator: phalanx

Math Functions

Postby kaye7877 » Sat Aug 28, 2010 7:00 pm

I'm having trouble getting some math functions to work in CCS. I can get the basic sin cos, etc. to work but not having any luck with pow(). Can someone shed some light on this?

How do I get the IDE to recognize the functions when I type them in? Is there a setting for that?
kaye7877
 
Posts: 7
Joined: Thu Aug 26, 2010 2:17 pm

Re: Math Functions

Postby bcgrown » Mon Aug 30, 2010 10:32 am

kaye7877 wrote:I'm having trouble getting some math functions to work in CCS. I can get the basic sin cos, etc. to work but not having any luck with pow(). Can someone shed some light on this?

How do I get the IDE to recognize the functions when I type them in? Is there a setting for that?


If you post your code and/or the compiler error it would be much easier to help you.

Have you added an #include statement for the relevant libraries?
bcgrown
 
Posts: 27
Joined: Sat Apr 24, 2010 7:59 am

Re: Math Functions

Postby kaye7877 » Fri Sep 03, 2010 8:57 pm

I gave up and changed the code so I don't have the original. I'm sure it is something I am not doing correctly.

I did include
math.h
float.h
The variables were also double as described in the header file.

Why, when I include them, do the functions not highlight in my CCS editor either?

I'll make some basic code and try it again and post the code.
kaye7877
 
Posts: 7
Joined: Thu Aug 26, 2010 2:17 pm

Re: Math Functions

Postby kaye7877 » Fri Sep 03, 2010 9:56 pm

The sin function works just fine. When I add the pow function in, the compiler gives me the following errors
errors encountered during linking; "Project010MathFunctions.out" not built
placement fails for object ".text",
placement fails for object ".text", size 0xa2e (page 0). Available ranges: FLASH size: 0x7e0 unused: 0x7b6 max hole: 0x7b6

// Written on CCS 4.x
//*****************************************************************************

#include "msp430g2211.h"
#include "float.h"
#include "math.h"

volatile float fTest = 0;
volatile double dTest = (45 * 3.1415926 / 180);
volatile double dResult1;
volatile double dResult2;
volatile double a = 2;
volatile double b = 2;
const unsigned int ctest = 100;

void main(void)
{

WDTCTL = WDTPW + WDTHOLD; // Hold watchdog timer.

// Port setups.
// Port 1 P1.3 is already wired to a SMD switch SW2.
P1DIR = 0xFF - BIT3; // Pins to be outputs
P1IE = BIT3;
P1OUT = 0;


// GIE must be enabled to allow any ISR to work. Can also be set by
// the command _enable_interrupts(void) and intrinsics.h must be included
_BIS_SR(GIE); // interrupt

for(;;)
{
}
}

// Interrupt service routine for Port 1
#pragma vector = PORT1_VECTOR
__interrupt void Port_1(void)
{

_BIC_SR(GIE); // Dis-allow interrupts
P1IFG = 0;
dResult1 = sin(dTest);
dResult2 = pow(a,b);


_BIS_SR(GIE); // interrupt
}
kaye7877
 
Posts: 7
Joined: Thu Aug 26, 2010 2:17 pm

Re: Math Functions

Postby UhClem » Sat Sep 04, 2010 12:57 am

kaye7877 wrote:The sin function works just fine. When I add the pow function in, the compiler gives me the following errors
errors encountered during linking; "Project010MathFunctions.out" not built
placement fails for object ".text",
placement fails for object ".text", size 0xa2e (page 0). Available ranges: FLASH size: 0x7e0 unused: 0x7b6 max hole: 0x7b6


The linker is telling you that you are trying to fit a square peg into a round hole. (code too big for memory)

Either redesign your code to control its size (avoiding library calls is good) or move to a part with more memory.
UhClem
 
Posts: 362
Joined: Sun Aug 03, 2008 6:11 pm

Re: Math Functions

Postby kaye7877 » Sat Sep 04, 2010 6:57 pm

Thank you.......
kaye7877
 
Posts: 7
Joined: Thu Aug 26, 2010 2:17 pm


Return to MSP Microcontrollers

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest