用MEGA16做NRF24L01无线的通信,只有51单片机的代码,且此代码程序在KEIL里面便已没有问题。移植到IAR之后出现如下错误提示:
Error[Pe147]: declaration is incompatible with "unsigned char __near TX_ADDRESS[5]" (declared at line 24)
错误的代码为:uchar TX_ADDRESS[TX_ADR_WIDTH] = {0x34,0x43,0x10,0x10,0x01}; // Define a static TX address
加个const后将其改为:uchar const TX_ADDRESS[TX_ADR_WIDTH] = {0x34,0x43,0x10,0x10,0x01}; // Define a static TX address
错误提示变成:Error[Pe167]: argument of type "unsigned char const *" is incompatible with parameter of type "unsigned char *"
错误地方为这个函数:SPI_Write_Buf(WRITE_REG + TX_ADDR,TX_ADDRESS, TX_ADR_WIDTH);
函数原型为:
uchar SPI_Write_Buf(BYTE reg, BYTE *pBuf, BYTE bytes)
{
uchar status,byte_ctr;
CSN = 0;
status = SPI_RW(reg);
for(byte_ctr=0; byte_ctr<bytes; byte_ctr++)
SPI_RW(*pBuf++);
CSN = 1;
return(status);
}
是什么原因呢?很晕,没遇见过。试了很久也没解决。望指点。 |