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.

IAR EW Error [e46]: Undefined external "xxxxx" referred in xxxxx

Other Parts Discussed in Thread: MSP430F2274, SIMPLICITI

Since using the SimpleApp sample project, I seem to be getting the e46 linker error rather regularly.  The confusing thing is that I'm pretty certain this has nothing to do with my code because I have successfully fixed this before by reverting the settings folder (containing the .cspy, .dbgdt, .dni and .wsdt files) and the SimpleCollectorEB folder(containing exe, list, and obj subfolders) to a working version.

It's not too big of a deal but it is annoying. Does anyone have a possible explanation for this?

  • Hello Angela,

    I don't think it is bug. Somewhere in your code you are trying to call something that isn't there. The first thing to do is go to Project and select Clean.  Then do a Build All.  If the problem is still there then go to Edit -> Find and Replace -> Find in Files and search for the external that is causing the error.  Or you can do the last step first, CTRL + SHIFT + F.

    Thanks,

  • I don't believe it's something in my code because without changing anything in my code, simply reverting non-source-code-related files fixes the issue.  

    I tried out your solution anyway and the result was the same error.  

  • greenja was partly right.  The problem was that I had set DMA to false in my config file. It seems like this has to be enabled for the sample code to work properly.  So far, I haven't had the problem since I enabled DMA.  I still think it's curious that reverting some object code files and IAR project settings would temporarily fix the error.  If anyone can shed some light on this, let me know :)

  • Hi Angela,

    I have the same error as you do, but I don't quite sure of what are you saying about "enable DMA". So could you explain it a little more please?

    Regards.

  • DMA was just an example there. What I was saying was that the error means that you are using a macro that has not been defined. I would check the bottom of the hal_board_config file and make sure that the necessary macros have been defined or enabled.

  • I see, but how can I do that? I really do not know

  • What is the exact error? 

  • Ok, I have written a code using the sample code that comes with the kit eZ430-RF2500, this kid includes the MSP430F2274 microcontroller, I'm pretty sure that you already know that. Now, here is the code:

    //****************************************************************************
    // ALGORITMO PARA EL "END DEVICE" POR JORGE AZUAJE Y JESÚS CARTAYA //
    //****************************************************************************

    //************************ Librerias *******************************************
    #include "bsp.h"
    #include "mrfi.h"
    #include "nwk_types.h"
    #include "nwk_api.h"
    #include "bsp_leds.h"
    #include "bsp_buttons.h"
    #include "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;
    }
    }
    }
    }

    And the error messages are the follows:

    Error[e46]: Undefined external "BSP_init" referred in main ( C:\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 )

    I can't even compile this, actually I'm stucked here. I will be really appreciative with you for your help.

    Thanks

  • where is BSP_init defined? I assume that it's in bsp.h? Do you have any #ifdefs that control whether this function is actually being run? The problem is that when your code calls BSP_init, the compiler cannot find it.

  • I have too problem with: "Undefined external". When I call function: InitRadio(); I get: "Undefined external: rfSettings, WriteRfSettings and WriteSinglePATable" but I have that in "RF1A.h". I running IAR v7. Any suggestion? Thanks.