天天看点

CC2530 Zigbee 开发常见问题

1.Warning[Pe069]: integer conversion resulted in truncation

CC2530 Sample工程用IAR Assembler for 8051 8.10.3 工具编译的时候提示“Warning[Pe069]: integer conversion resulted in truncation”警告信息,虽然不影响功能,但是对于有强迫症的开发者来说,看着还是很不舒服的,查看警告的地方,源码如下:

#define HAL_DMA_SET_ADDR_DESC0( a ) \
  st( \
    DMA0CFGH = (uint8)( (uint16)(a) >> 8 );  \
    DMA0CFGL = (uint8)( (uint16)(a) );       \
  )
           

按照下述方式修改代码:

#define HAL_DMA_SET_ADDR_DESC0( a ) \
  st( \
    DMA0CFGH = (uint8)( (uint16)(a) >> 8 );  \
    DMA0CFGL = (uint8)( (uint16)(a) & 0x00ff );       \
  )
           

重新编译之后,就没有警告信息了,看到“Total number of warnings: 0 ”开心多了。

2.Error[Pa045]: function "get_dev_info" has no prototype C:

CC2530 Sample工程用IAR Assembler for 8051 8.10.3 工具编译的时候,提示“Error[Pa045]: function "get_dev_info" has no prototype C:”错误,出现错误的代码如下:

static void get_dev_info()
{
    ...
}
           

对于该问题,有两种解决的方法:

(1)出现上述问题,是因为该函数没有输入参数,并且空着,如果你的函数没有输入参数的话,在输入参数的位置写个“void”,如下所示:

static void get_dev_info( void )
{
    ...
}
           

这种解决方式是比较规范的。

(2)放弃prototype检测

在IAR打开工程的界面,左侧工程名上右键,然后点击“Options...”,按照如下截图操作:

CC2530 Zigbee 开发常见问题

将“Require prototype”前面的勾去掉,然后点“OK”,重新编译即可。

继续阅读