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.

cc2541 IAR 编译报错 Range error

Other Parts Discussed in Thread: CC2541DK-MINI

和这个贴的情况一模一样

e2echina.ti.com/.../92218

大概是程序超过一个BANK?注释掉一点程序就可以,只要加一点程序都不行,看似乎是空间不够,但整个项目才100多K

  • 你是編譯沒有修改過的源程序看到这樣的問題還是你修改過的程序
  • map文件看一下内存占用情况
  • 程序一直在修改都没事,昨天加了些程序就不行,但把其它没用的删掉一点就可以
  • 编译不过,map文件没有信息吧,是看正常的情况下吗?
  • 你用的BLE Stack版本跟原始例程上那一個?
  • 我用的是stack是1.4.2.2  , IAR 9.10.3,  例改自simpleBLEPeripheral例程, MAP文件内容是这样的:

    Error[e18]: Range error,

    Number out of range

    File: C:\Texas Instruments\BLE-CC254x-1.4.2.2\Projects\ble\SolarStreetlight\Source\simpleBLEPeripheral.c, Line: 1857

    Source: LJMP    ??powerControlTask_2

     Where $ = powerControlTask + 0x1B5CD  [0x1B5CD]

               in module "simpleBLEPeripheral" (C:\Texas Instruments\BLE-CC254x-1.4.2.2\Projects\ble\SolarStreetlight\CC2541DB\CC2541DK-MINI Keyfob\Obj\simpleBLEPeripheral.r51),

               offset 0x50 in segment part 124, segment BANKED_CODE

     What: (powerControlTask + 0xEF) [0x1B66C]

     Allowed range: 0xFFFF8000 - 0xFFFF

     Operand: powerControlTask [0x1b66c]

              in module simpleBLEPeripheral (C:\Texas Instruments\BLE-CC254x-1.4.2.2\Projects\ble\SolarStreetlight\CC2541DB\CC2541DK-MINI Keyfob\Obj\simpleBLEPeripheral.r51),

              Offset 0xef in segment part 124, segment BANKED_CODE

  • 如果你是加了太多自己的應用程序上去導致flash用光了,那就沒什麼好辦法解決
  • 问题是没有用光啊,正常的时候是
    ****************************************
    * *
    * END OF CROSS REFERENCE *
    * *
    ****************************************

    116 497 bytes of CODE memory
    34 bytes of DATA memory (+ 84 absolute )
    6 497 bytes of XDATA memory
    194 bytes of IDATA memory
    8 bits of BIT memory
    561 bytes of CONST memory

    Errors: none
    Warnings: none

    然后我加几条代码就变成了上面说的情况,芯片不是256K吗?
  • 你加了哪几条代码?
  • 真的好奇怪,已经排除了空间不足问题,出现得比较随机,偶尔出现,举个例子,只是一种情况,如下
    if(condition)
    {
    //do something
    }
    else
    {
    // do something
    }
    这时编译不通过!
    当我改成
    if(condition)
    {
    //do something
    }
    //else //注释了else
    {
    // do something
    }
    就通过了

    还有一种解决办法,当出现不通过时,只要我在程序中特定位置加入nop就能能解决,如改成如下
    if(condition)
    {
    //do something
    asm("nop");
    }
    else 
    {
    // do something
    }
    它又能链接成功了!

  • 把你会出錯的程序貼上好嗎?
  • e2echina.ti.com/.../165270 我精简了代码放上来,麻烦帮忙 看看,谢谢
  • 不是说只有加几行代碼就會有問題、把那几行貼出來就好
  • 这是我之前贴,找了很久没找到原因,麻烦帮忙看看,e2echina.ti.com/.../165033

    这次我精简了代码,定位到一个函数里,这个函数精简过没有什么意义,但能重现问题。源代码见附件。

    感觉各IAR的高优化有关。。

    Building configuration: SimpleBLEPeripheral - CC2541DK-MINI Keyfob
    Updating build tree...
    Linking
    Error[e18]: Range error,
    Number out of range
    File: C:\Texas Instruments\BLE-CC254x-1.4.2.2\Projects\ble\SolarStreetlight\Source\simpleBLEPeripheral.c, Line: 1014
    Source: LJMP ??powerControlTask_2
    Where $ = powerControlTask + 0x2F5AE [0x2F5AE]
    in module "simpleBLEPeripheral" (C:\Texas Instruments\BLE-CC254x-1.4.2.2\Projects\ble\SolarStreetlight\CC2541DB\CC2541DK-MINI Keyfob\Obj\
    simpleBLEPeripheral.r51),
    offset 0x30 in segment part 40, segment BANKED_CODE
    What: (powerControlTask + 0xB2) [0x2F630]
    Allowed range: 0xFFFF8000 - 0xFFFF
    Operand: powerControlTask [0x2f630]
    in module simpleBLEPeripheral (C:\Texas Instruments\BLE-CC254x-1.4.2.2\Projects\ble\SolarStreetlight\CC2541DB\CC2541DK-MINI Keyfob\Obj\
    simpleBLEPeripheral.r51),
    Offset 0xb2 in segment part 40, segment BANKED_CODE
    Error while running Linker

    Total number of errors: 1
    Total number of warnings: 0

    SolarStreetlight.rar

  • 已經在你另一個重複的帖子e2echina.ti.com/.../485795 回覆你了
  • e2echina.ti.com/.../SolarStreetlight.rar
    请看代码

    //#pragma optimize = none  单独不开优化也可以
    static void powerControlTask(void)
    {
    	uint16 adcBat, adcSolar;
    	uint8 i;
    	
    	if (filterInitCnt > 0)
    	{
    		filterInitCnt--;
    		//adcBatFilter.cnt = 0;
    		//adcSolarFilter.cnt = 0;
    		//adcBatSmoothRaw = 0;
    		for (i = 0; i < 8; i++)
    		{
    			adcBat = HalAdcRead(HAL_ADC_CHANNEL_7, HAL_ADC_RESOLUTION_12);
    			//adcSolar = HalAdcRead(HAL_ADC_CHANNEL_6, HAL_ADC_RESOLUTION_12);
    			adcBatSmoothRaw += adcBat >> SMOOTH_FILTER_GAIN;
    		}
            // asm("nop"); //在这加nop 可以链接成功
    	}
        else
    	{
    		adcBat = HalAdcRead(HAL_ADC_CHANNEL_7, HAL_ADC_RESOLUTION_12);
    		adcSolar = HalAdcRead(HAL_ADC_CHANNEL_6, HAL_ADC_RESOLUTION_12);
    
    		if (adcBatFilter.cnt >= FILTER_BUFF_SIZE_BAT)
    		{
    			adcBatFilter.cnt = 0;
    			adcBatFilterRaw = adcBatFilter.buff[2];
    			adcBatSmoothRaw -= adcBatSmoothRaw >> SMOOTH_FILTER_GAIN;
    			adcBatSmoothRaw += adcBatFilter.buff[2] >> SMOOTH_FILTER_GAIN;
    		}
    
    		if (adcSolarFilter.cnt >= FILTER_BUFF_SIZE_SOLAR)
    		{
    			adcSolarFilter.cnt = 0;
    			adcSolarFilterRaw = adcSolarFilter.buff[1];
    		}
    	}
    
    }

  • 參考一下 IAR在 supp.iar.com/.../xman.ENU.html 對 range error的說明
  • 我以前公司电脑中安装的有加密软件,经常会导致这样的问题,不知道你的电脑可有类似的加密软件