Search code examples
cmsp430texas-instrumentscode-composer

TI CC3100 getting_started_with_wlan_station example gives linker error


I am trying to send some sensor values read through ADC on a port of MSP430F5529 to an access point using CC3100. I took the getting_started_with_wlan_station example from the CC3100SDK_1.2.0 and added the MSP430F55xx_adc_01.c code from the slac300i.

Here is how it looks like: This function configures the ADC

static void read_adc(void){
    ADC12CTL0 = ADC12SHT02 + ADC12ON;         // Sampling time, ADC12 on
    ADC12CTL1 = ADC12SHP;                     // Use sampling timer
    ADC12IE = 0x01;                           // Enable interrupt
    ADC12CTL0 |= ADC12ENC;
    P6SEL |= 0x01;                            // P6.0 ADC option select
    P1DIR |= 0x01;                            // P1.0 output
}

The main function has

read_adc();
while(1){
    /* Read ADC values*/
    ADC12CTL0 |= ADC12SC;                   // Start sampling/conversion
    adc_values = ADC12MEM0 & 0x0FFF; // keep only low 12 bits
    CLI_Write((_u8 *) adc_values);
    CLI_Write((_u8 *)"\n");
    __bis_SR_register(LPM0_bits + GIE);     // LPM0, ADC12_ISR will force exit
    __no_operation();                       // For debugger
}

On building the project, there is a linker error

<Linking>
error #10056: symbol "__TI_int54" redefined: first defined in "./main.obj"; redefined in "./board/board.obj"
error #10010: errors encountered during linking; "getting_started_with_wlan_station.out" not built

>> Compilation failure
makefile:165: recipe for target 'getting_started_with_wlan_station.out' failed
gmake: *** [getting_started_with_wlan_station.out] Error 1
gmake: Target 'all' not remade because of errors.

This error shows up because of adding the following section in the code, which is also taken from slac300i

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12_ISR (void)
#else
#error Compiler not supported!
#endif
{
    switch(__even_in_range(ADC12IV,34))
    {
    case  0: break;                           // Vector  0:  No interrupt
    case  2: break;                           // Vector  2:  ADC overflow
    case  4: break;                           // Vector  4:  ADC timing overflow
    case  6:                                  // Vector  6:  ADC12IFG0
        if (ADC12MEM0 >= 0x7ff)                 // ADC12MEM = A0 > 0.5AVcc?
            P1OUT |= BIT0;                        // P1.0 = 1
        else
            P1OUT &= ~BIT0;                       // P1.0 = 0

        __bic_SR_register_on_exit(LPM0_bits);   // Exit active CPU
    case  8: break;                           // Vector  8:  ADC12IFG1
    case 10: break;                           // Vector 10:  ADC12IFG2
    case 12: break;                           // Vector 12:  ADC12IFG3
    case 14: break;                           // Vector 14:  ADC12IFG4
    case 16: break;                           // Vector 16:  ADC12IFG5
    case 18: break;                           // Vector 18:  ADC12IFG6
    case 20: break;                           // Vector 20:  ADC12IFG7
    case 22: break;                           // Vector 22:  ADC12IFG8
    case 24: break;                           // Vector 24:  ADC12IFG9
    case 26: break;                           // Vector 26:  ADC12IFG10
    case 28: break;                           // Vector 28:  ADC12IFG11
    case 30: break;                           // Vector 30:  ADC12IFG12
    case 32: break;                           // Vector 32:  ADC12IFG13
    case 34: break;                           // Vector 34:  ADC12IFG14
    default: break;
    }
}

However, if I comment this out, the debugger gets stuck in the infinite loop in the following section of board.c file, present in the project

/* Catch interrupt vectors that are not initialized. */
#ifdef __CCS__
#pragma vector=WDT_VECTOR, ADC12_VECTOR, USCI_B1_VECTOR, \
    TIMER1_A1_VECTOR, TIMER0_A1_VECTOR, \
    TIMER2_A1_VECTOR, COMP_B_VECTOR, USB_UBM_VECTOR, UNMI_VECTOR,DMA_VECTOR, \
    TIMER0_B0_VECTOR, TIMER0_B1_VECTOR,SYSNMI_VECTOR, USCI_B0_VECTOR, RTC_VECTOR
__interrupt void Trap_ISR(void)
{
    while(1);
}

Please suggest what I am missing in the initialization of the interrupt, which seems to be the problem. Or am I missing something else?


Solution

  • __TI_int54 is the memory word in which the address of the ADC12 interrupt handler is stored.

    You are trying to define two interrupt handlers for the same interrupt, ADC12_ISR() and Trap_ISR(). The latter is intended only to catch interrupts for which no actual handler exists, so you must remove ADC12_VECTOR from its list.