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.

cc2538 build error

Other Parts Discussed in Thread: CC2538

Hi

Am trying to interface the heartbeat sensor on cc2538 board.While building am getting some errors....Can anyone please suggest some solution for this???

Error is cannot open the source file....

  • Try to put the path of hw_gpio.h and hw_gptimer.h into "Additional standard include directories" of Preprocessor options.

  • Thanks for the reply...

    At the time of linking the files, am getting the below attached error.... 

    could anyone please suggest the solution for this...???

  • Hi,

    The linker cannot find the listed functions. Have you forgotten to include ssi.c in your project?

    Br,
    TIABO

  • Thanks for the reply...

    Actually am trying to interface the heartbeat sensor on cc2538 board....but am unable to get the output...

    Am attaching my piece of code and the screenshot at the time of output....

    It would be very helpful for me if anyone suggest some solution for this....

    6457.main.c
    
    #include <stdio.h>
    #include <stdbool.h>
    #include <stdint.h>
    #include "hw_ints.h"
    #include "hw_memmap.h"
    #include "gpio.h"
    #include "ioc.h"
    #include "hw_ioc.h"
    #include "sys_ctrl.h"
    #include "gptimer.h"
    #include "hw_gptimer.h"
    #include "interrupt.h"
    #include "adc.h"
    #include "hw_sys_ctrl.h"
    #include "systick.h"
    #include "hw_cctest.h"
    #include "hw_rfcore_xreg.h"
    #include "lcd_dogm128_6.h"
    
    #define HEARTRATE_GPIO_BASE               GPIO_C_BASE
    #define HEARTRATE_GPIO_PIN                GPIO_PIN_3
    #define HEARTRATE_INT_GPIO                INT_GPIOC
    
    
    //adc
    #define CONST 0.58134 //(VREF / 2047) = (1190 / 2047), VREF from Datasheet
    #define OFFSET_DATASHEET_25C 827 // 1422*CONST, from Datasheet 
    #define TEMP_COEFF (CONST * 4.2) // From Datasheet
    #define OFFSET_0C (OFFSET_DATASHEET_25C - (25 * TEMP_COEFF))
    
    uint32_t avg_pul_int=0, clk_dur, Time_between_pul, Bpm;
    
    uint16_t ui16Dummy;//adc
    double dOutputVoltage;//adc
    char pcTemp[20];//adc
    uint32_t tim_val;
    int even_odd=0, p=0, i, j;
    
    void clockinit(void)
    {
      SysCtrlClockSet(false, false, SYS_CTRL_SYSDIV_250KHZ);
      SysCtrlIOClockSet(SYS_CTRL_SYSDIV_250KHZ);
    }
    void heartratecode(void)
    {
         
       
       avg_pul_int = tim_val/5;
      
      clk_dur = 1/ SYS_CTRL_SYSDIV_250KHZ;
      
      Time_between_pul = (clk_dur * avg_pul_int);
      
      Bpm = 60/Time_between_pul ;
      
      //UARTprintf("heartrate = %d Bpm", Bpm);
     
    }
    
    void tempsensorinit(void)
    {
       // Connect temp sensor to ADC
        HWREG(CCTEST_TR0) |= CCTEST_TR0_ADCTM;
    
        // Enable the temperature sensor 
        HWREG(RFCORE_XREG_ATEST) = 0x01;
        
        // Configure ADC, Internal reference, 512 decimation rate (12bit)
        SOCADCSingleConfigure(SOCADC_12_BIT, SOCADC_REF_INTERNAL);
    }
    
    void tempsensorcode(void)
     {
        
        
        SOCADCSingleStart(SOCADC_TEMP_SENS);
        while(!SOCADCEndOfCOnversionGet());
        ui16Dummy = SOCADCDataGet() >> SOCADC_12_BIT_RSHIFT;
        dOutputVoltage = ui16Dummy * CONST;       
        dOutputVoltage = ((dOutputVoltage - OFFSET_0C) / TEMP_COEFF);
        sprintf(pcTemp, "%.1f", dOutputVoltage);
     }
    
    void GPIOCIntHandler(void)
    {
      
      switch(even_odd)
      {
        case(0):{  //TimerIntClear(GPTIMER0_BASE, GPTIMER_B, uint32_t ui32IntFlags);
           //        int ovf_count=0;
                   GPIOPinIntClear(HEARTRATE_GPIO_BASE, HEARTRATE_GPIO_PIN);
                   TimerEnable(GPTIMER0_BASE, GPTIMER_BOTH);
                   even_odd++;
                    /*              while(1)
                   { 
                    
                    if(GPTIMER_O_RIS && GPTIMER_RIS_TBTO)
                    {
                      TimerIntClear(GPTIMER0_BASE, GPTIMER_TIMB_TIMEOUT);
                      ovf_count++;
                    }
                   } */
                   break;
                }   
        case(1):{ 
                  GPIOPinIntClear(HEARTRATE_GPIO_BASE, HEARTRATE_GPIO_PIN);
                  TimerDisable(GPTIMER0_BASE, GPTIMER_BOTH);
                  even_odd--;
                  p++;
                  if(p==5)
                  {
                    p=0;
                    tim_val = HWREG(GPTIMER_O_TBR);
                  }
                  break;
                }
                  
    
                  
                  
                   
        }    
    }              
                     
                     
                     
    
    void lcdcode(void)
    {
      lcdBufferPrintString(0,"Temperature: ", 0, eLcdPage0);
      lcdBufferPrintString(0,"Heartrate: ", 0, eLcdPage1);
      
      lcdBufferClearPart(0, 15 * LCD_CHAR_WIDTH, 127, eLcdPage0, eLcdPage1);
      
      lcdBufferPrintFloat(0, dOutputVoltage, 3, 15 * LCD_CHAR_WIDTH, eLcdPage0);
      lcdBufferPrintInt(0, Bpm, 15 * LCD_CHAR_WIDTH, eLcdPage1);
      
      lcdSendBufferPart(0, 15 * LCD_CHAR_WIDTH, 127, eLcdPage0, eLcdPage1);
    }
        
      
    void main(void)
    {
      clockinit();
      tempsensorinit();
      lcdInit();
      
     // lcdBfferClear(0);
      
      SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_RFC);
        
      TimerConfigure(GPTIMER0_BASE, GPTIMER_CFG_ONE_SHOT_UP);
      GPIOPinTypeGPIOInput(HEARTRATE_GPIO_BASE, HEARTRATE_GPIO_PIN);
      IOCPadConfigSet(HEARTRATE_GPIO_BASE, HEARTRATE_GPIO_PIN, IOC_OVERRIDE_PUE);
      
      GPIOIntTypeSet(HEARTRATE_GPIO_BASE, HEARTRATE_GPIO_PIN, GPIO_RISING_EDGE);
      
      GPIOPinIntEnable(HEARTRATE_GPIO_BASE, HEARTRATE_GPIO_PIN);
      IntRegister(HEARTRATE_INT_GPIO, GPIOCIntHandler);
      //IntMasterEnable();
      
      IntEnable(HEARTRATE_INT_GPIO);
      
      while(1)
      {
      tempsensorcode();
      
      heartratecode();
      
      lcdcode();
      
      for(i=0;i<10000;i++)
        for(j=0;j<10;j++);
        
      }
      
    } 
      
    
    
    
    
    

  • Is the issue that you're unable to print the values on the LCD, or that the Bpm variable isn't correct?

    You are getting some stack errors, you may want to increase your stack size (or reduce use of variables placed on stack).

    Br,
    TIABO

  • Do you mean that you don't see output on LCD? If this is the problem, check if you enable "#define HAL_LCD TRUE".

  • Am unable to print the values on LCD...after debugging I pressed the reset button but its showing the previously dumped code....

    I think because of stack size am unable to print the values on LCD.....

    Could you please suggest the solution for this...?

  • Thanks for the reply....

    Yes am unable to see the output on LCD...Its showing the previously dumped output....

    Could u please suggest me how could I check if  "#define HAL_LCD TRUE" is enable or not....?

  • I see that you use lcdInit directly so you don't have to put "#define HAL_LCD TRUE" in your code. But, I see you don't put "bspSpiInit(SPI_CLOCK);" before lcdInit(). Please revise your code like the followings:

    #define SPI_CLOCK 2000000UL

    ...

    void main(void)
    {
      ..
      bspSpiInit(SPI_CLOCK);
      lcdInit();
    ...

  • Thanks for the reply...

    but still its not printing the values on LCD....

    am attaching the error....please anyone suggest some solution for this....

  • Do you use SmartRF06EB with CC2538EM? Or your code runs on your own PCB?
  • Yes am using SmartRF06EB with CC2538EM.....

  • Try to refer to the example in Chapter 9 in SWRU327 User’s Guide SmartRF06EB Board Support Package.

  • Hi,

    1. If you disable "Run to main" under Project > Options > Debugger > Setup tab, you should be able to track the stack usage and see where it explodes.

    2. You can try to increase the stack size, you can normally do this by updating your linker configuration file (.icf).

    Br,
    TIABO

  • If you install CC2538 Foundation Firmware, there is a LCD example under C:\Texas Instruments\swrc271a\cc2538_foundation_firmware_1_0_1_0\bsp\srf06eb_cc2538\examples\lcd\projects\iar