# Compiling MSP430 files linking problems

I'm trying to compile a simple C file to later upload to my MSP430 uC but when I try to compile I get something that looks like a linking problem:

main.c:7: undefined reference to outPWM'


my folder contains these files:

1. main.c
2. pwm.h
3. pwm.c

main.c only has this simple instructions:

#include <io.h>
#include <stdint.h>
#include "pwm.h"
int main( void ){
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
outPWM(1,4,100);
return 0;
}


pwm.h only has the function prototype and some macros:

#define MCU_CLOCK       160000000
#define PWM_FREQUENCY   50
//Set z% PWM duty cicle output on port x.y
int outPWM(uint8_t x,uint8_t y,uint8_t z);


and pwm.c has the function that is quite big so just for the sake of the example it will be this:

#include <io.h>
#include <signal.h>
#include "pwm.h"

int outPWM(uint8_t port,uint8_t sel,uint8_t PWM_Duty){
return 0;
}
`

I might be using the wrong options while compiling but I have no idea what should I use besides what is provided in some examples on the web that I adapted to this: msp430-gcc main.c -mmcu=msp430x2252 -O2 -Wall -o main.o

What am I doing wrong?

Thank you.

EDIT Corrected function name in pwm.c

• Which toolchain are you using? – AndrejaKo Jul 22 '12 at 14:36
• @AndrejaKo I'm using msp430-gcc in linux – Leonardo Marques Jul 22 '12 at 14:40
• there is no outPWM function mention in pwm.c ? – pstan Jul 22 '12 at 16:05
• @pstan there is, it was my mistake when writing the question I'm sorry – Leonardo Marques Jul 22 '12 at 19:15