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.

Error[e46]: Undefined external "BSP_init" referred in main ( C:\Users\Luis\Desktop\Tesis\pruebas\Debug\Obj\main.r43 )

Other Parts Discussed in Thread: MSP430F2274, SIMPLICITI

Hello,

I'm using eZ430-RF2500 which is MSP430F2274 series and i wanna connect to external temperature sensor. This temperature sensor sends binary frames to our PC, and i want to adapt it to an ED. I am using the demo_ED that comes with the kit. Below is the code that I have written  but it show me the follow erros and I don't know why is this happening. So, I am stucked here, I will appreciate if anybody helps me.

Thanks.

Jesus.

//************************ Librerias *******************************************
#include "C:\Users\Luis\Desktop\eZ430-RF2500 Wireless Sensor Monitor\Embedded\IAR\Components\bsp\bsp.h"
#include "C:\Users\Luis\Desktop\eZ430-RF2500 Wireless Sensor Monitor\Embedded\IAR\Components\bsp\mrfi.h"
#include "C:\Users\Luis\Desktop\eZ430-RF2500 Wireless Sensor Monitor\Embedded\IAR\Components\bsp\nwk_types.h"
#include "C:\Users\Luis\Desktop\eZ430-RF2500 Wireless Sensor Monitor\Embedded\IAR\Components\bsp\nwk_api.h"
#include "C:\Users\Luis\Desktop\eZ430-RF2500 Wireless Sensor Monitor\Embedded\IAR\Components\bsp\bsp_leds.h"
#include "C:\Users\Luis\Desktop\eZ430-RF2500 Wireless Sensor Monitor\Embedded\IAR\Components\bsp\bsp_buttons.h"
#include "C:\Users\Luis\Desktop\eZ430-RF2500 Wireless Sensor Monitor\Embedded\IAR\Components\bsp\vlo_rand.h"
#include "msp430f2274.h"

//******************* Definiciones *********************************************
#define MISSES_IN_A_ROW 5 //define los intentos maximos a establecer conexion
#define Almacenamiento 9 //indica que el bufer utilizado llega al máximo

//************************Funciones de la Red*********************************
void MCU_init(void); // Inicialización del Microcontrolador
void linkTo(void); // Creación del Enlace
void createRandomAddress (); // Creación de las direcciones
void TXString(char* string, int length); // Transmisión del mensaje (mensaje + longitud)

//***************************Uso de la memoria flash****************************
__no_init volatile char Flash_Addr[4] @ 0x10F0; //Espacio de memoria Flash para almacenar 4 direcciones
addr_t Direcciones; //variable para almacenar direcciones

//**Variables relacionadas con el buffer de UART y los datos recibidos del RS232**
volatile static uint8_t Dato_Recibido_SizeUART=0,Dato_Recibido_SizeUART2=0; //vectores que recibiran los datos de la tarjeta
static uint8_t Dato_Recibido_UART[Almacenamiento], Dato_Recibido_UART2[Almacenamiento]; //dos arreglos de 8 posiciones
volatile int buffer_utilizado=1,buffer_que_envia=0; //indentificador del buffer que se esta usando y del que envia

//******************************************************************************
// PROGRAMA PRINCIPAL //
//******************************************************************************

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; //Detiene en WDT

//*****************Ciclo que asegura un inicio correcto***********************
volatile int j;
for(j=0; j<0xFFFF; j++)
{}

//*****************Calibración de los Dispositivos****************************
if(CALBC1_8MHZ==0xFF)
{
volatile int i;
P1DIR|=0x03; //en el puerto 1, los terminales 1 y 2 son salidas y el resto como entradas
BSP_TURN_ON_LED1(); // Prende en LED Rojo
BSP_TURN_OFF_LED2(); // Apaga el LED Verde
while(1)
{
for(i=0; i<0x5FFF; i++)
{}
BSP_TOGGLE_LED2();
BSP_TOGGLE_LED1();
}
}
//*******SimpliciTI cambiará la configuración de los puertos como sigue*******
P1DIR=0xFF; // Dirección del puerto 1
P1OUT=0x00; // Dirección de la salida del puerto 1
P2DIR=0x27;
P2OUT=0x00;
P3DIR=0xC0;
P3OUT=0x00;
P4DIR=0xFF;
P4OUT=0x00;

//**************** Inicialización del Hardware *******************************
BSP_init();

if(Flash_Addr[0]==0xFF && Flash_Addr[1]==0xFF && Flash_Addr[2]==0xFF && Flash_Addr[3]==0xFF)
{
createRandomAddress(); // Se llama la función para obtener las direcciones
}

//********************* Se almacenan las Direcciones**************************
Direcciones.addr[0]=Flash_Addr[0];
Direcciones.addr[1]=Flash_Addr[1];
Direcciones.addr[2]=Flash_Addr[2];
Direcciones.addr[3]=Flash_Addr[3];
SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &Direcciones); //Configuración del tiempo de ejecución

//*************************Inicializamos El Micro*******************************
BCSCTL1=CALBC1_8MHZ; // configura el parametro DCO
DCOCTL=CALDCO_8MHZ;
BCSCTL3|=LFXT1S_2; //LFXT1=VLO
TACCTL0=CCIE; //interrupcion por TACCR0 habilitada
TACCR0=12000; //~1 segundo
TACTL=TASSEL_1+MC_1; //ACLK, upmode
P3SEL|=0x30; //P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1=UCSSEL_2; // SMCLK
UCA0BR0=0x41; // 9600 de 8MHz
UCA0BR1=0x3;
UCA0MCTL=UCBRS_2;
UCA0CTL1&=~UCSWRST; // Incializa el estado de la máquina USCI
IE2|=UCA0RXIE; //habilita la interrupción por USCI_A0 RX

//***************Ciclo de espera de conexión del ED con el AP*****************
while(SMPL_NO_JOIN==SMPL_Init((uint8_t (*)(linkID_t))0))
{
BSP_TOGGLE_LED1();
BSP_TOGGLE_LED2();
__bis_SR_register(LPM3_bits+GIE);
}

//Llamamos a la funcion linkTo al realizar una conexion con el AP exitosamente
linkTo();
}
//******************************************************************************
// FIN DEL PROGRAMA PRINCIPAL //
//******************************************************************************

//**********************Creación de las Direcciones*****************************
void createRandomAddress()
{
unsigned int rand, rand2;
do
{
rand = TI_getRandomIntegerFromVLO(); //el primer byte no puede ser 0x00 ni 0xFF
}
while((rand & 0xFF00)==0xFF00||(rand & 0xFF00)==0x0000);
rand2 = TI_getRandomIntegerFromVLO();

BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1MHz
DCOCTL = CALDCO_1MHZ;
FCTL2 = FWKEY + FSSEL0 + FN1; // MCLK/3 for Flash Timing Generator
FCTL3 = FWKEY + LOCKA; // Clear LOCK & LOCKA bits
FCTL1 = FWKEY + WRT; // Set WRT bit for write operation

Flash_Addr[0]=(rand>>8) & 0xFF;
Flash_Addr[1]=rand & 0xFF;
Flash_Addr[2]=(rand2>>8) & 0xFF;
Flash_Addr[3]=rand2 & 0xFF;

FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCKA + LOCK; // Set LOCK & LOCKA bit
}

//*************************Creación del Enlace**********************************
void linkTo()
{
linkID_t linkID1;

// Inicializa los LEDs
BSP_TURN_OFF_LED1();
BSP_TURN_OFF_LED2();

// Intenta establecer el enlace...
while (SMPL_SUCCESS != SMPL_Link(&linkID1))
{
__bis_SR_register(LPM3_bits + GIE); // LPM3 with interrupts enabled
BSP_TOGGLE_LED1();
BSP_TOGGLE_LED2();
}

for(int i=0; i<5; i++)
{
Dato_Recibido_UART2[i]=(uint8_t)(65+i);
Dato_Recibido_SizeUART2=5;
}

while(1)
{
if(buffer_que_envia==1)
{
if (SMPL_SUCCESS==SMPL_Send(linkID1, Dato_Recibido_UART, Dato_Recibido_SizeUART)) //se envian los datos vía Zigbee al buffer Dato_Recibido_UART
{
Dato_Recibido_SizeUART=0; //
buffer_que_envia = 0;
BSP_TOGGLE_LED2(); // Durante la transmisión de datos el LED verde papardea
BSP_TURN_OFF_LED1(); // Durante la transmisión de datos el LED rojo está apagado
}
}
if(buffer_que_envia==2) // if(Dato_Recibido_SizeUART2==Almacenamiento)
{
if (SMPL_SUCCESS == SMPL_Send(linkID1, Dato_Recibido_UART2, Dato_Recibido_SizeUART2))
{
Dato_Recibido_SizeUART2 = 0; // Si los datos han sido enviados con éxito inicializamos el buffer RX a 0
buffer_que_envia = 0;
BSP_TURN_OFF_LED1(); // Durante la transmisión de datos el LED rojo está apagado
BSP_TOGGLE_LED2(); // Durante la transmisión de datos el LED verde parpadea
}
}
}
}

//***************Transmitimos en Mensaje = Mensaje + longitud*******************
void TXString( char* string, int length )
{
int pointer;
for( pointer = 0; pointer < length; pointer++)
{
volatile int i;
UCA0TXBUF = string[pointer];
while (!(IFG2&UCA0TXIFG)); // Mientras el buffer esté listo (ocupado)
}
}
//******************************************************************************
// Timer A0 interrupt service routine
//******************************************************************************
#pragma vector = TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
__bic_SR_register_on_exit(LPM3_bits); // Clear LPM3 bit from 0(SR)
}

//****************Preparamos la trama que queremos enviar***********************
#pragma vector = USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
uint8_t rx = UCA0RXBUF;
if (buffer_utilizado==1)
{
if (Dato_Recibido_SizeUART < Almacenamiento)
{
BSP_TOGGLE_LED1(); // Mientras se reciben los datos parpadea el led rojo
Dato_Recibido_UART[Dato_Recibido_SizeUART++] = rx ; //
}
else
{
buffer_que_envia=1;
buffer_utilizado=2;
Dato_Recibido_SizeUART2=0;
}
if (buffer_utilizado==2)
{
if (Dato_Recibido_SizeUART2 < Almacenamiento)
{
BSP_TOGGLE_LED1(); // Mientras se reciben los datos parpadea el led rojo
Dato_Recibido_UART2[Dato_Recibido_SizeUART2++] = rx;
}
else
{
buffer_que_envia=2;
buffer_utilizado=1;
Dato_Recibido_SizeUART=0;
Dato_Recibido_UART[Dato_Recibido_SizeUART++] = rx;
}
}
}
}

The erros that it shows are:

Error[e46]: Undefined external "BSP_init" referred in main ( :\Users\Luis\Desktop\Tesis\pruebas\Debug\Obj\main.r43 )


Error[e46]: Undefined external "SMPL_Ioctl" referred in main ( C:\Users\Luis\Desktop\Tesis\pruebas\Debug\Obj\main.r43 )


Error[e46]: Undefined external "SMPL_Init" referred in main ( C:\Users\Luis\Desktop\Tesis\pruebas\Debug\Obj\main.r43 )


Error[e46]: Undefined external "TI_getRandomIntegerFromVLO" referred in main ( C:\Users\Luis\Desktop\Tesis\pruebas\Debug\Obj\main.r43 )


Error[e46]: Undefined external "SMPL_Link" referred in main ( C:\Users\Luis\Desktop\Tesis\pruebas\Debug\Obj\main.r43 )


Error[e46]: Undefined external "SMPL_Send" referred in main ( C:\Users\Luis\Desktop\Tesis\pruebas\Debug\Obj\main.r43 )


Error while running Linker

  • Including the header files tells the compiler that there is somewhere something called 'BSP_init' or whatever, but it does not provide it.
    So the compiler will accept its use when compiling your code, and will forward its integration to the linker. And the linker then cannot find it and complains.

    You apparently forgot to include the actual code for these functions. Either by adding the .c file in which the code is to your project (just copying the file into the project folder isn't enough) Or you forgot to tell the linker to use a precompiled library and include it into the binary.

  • Hi Jens-Michael,

    This is my first time using the iar complier and I'm really don't know how to use it. I'm not quite understand what you've said, so could you please explain it for dummies?

    Regards.

  • This is not IAR specific.

    The header files, which you include, do not contain actual code (at least they should, even though Microsoft uses them to include code in their VisulaSomething projects)
    header files tell the compiler about code that is compiled separately but can be used in the code file that is currently compiled.
    To actually add the 'external' code to your project, so that the linker can link it, you need to tell the build process which files have to be compiled, and tell the linker, which files (including libraries) have to be linked.

    YOu include lots of heade rfiles in your program, and use funcitons that are declared (but not defined) in them.
    So you have to add the files in which they are defined (the code files) to your project in the project settings, so that the compiler will compile them too and the linker can link them.

    In your case, the header files tell the compile rthat there is a funciton 'BSP_init' with this or that parameters and return value somewhere. So the compiler iwll compile your code that is callign this function. However, the code file in which the function is coded, is not part of your project, the compiler doesn't compile it and then the linker cannot add it to the binary.

**Attention** This is a public forum