View previous topic :: View next topic |
Author |
Message |
lgeorge123
Joined: 05 Dec 2004 Posts: 31
|
convert 8051 c to ccs c compiler |
Posted: Mon Jun 12, 2006 9:37 am |
|
|
I have a portion of 8051 c , i wish to convert to ccs c ,can anyone help me ? the portion to be converted is underline.
mifs_value(unsigned char _Mode,unsigned char _Adr,long *_Value,unsigned char _Trans_Adr)
{
[u]unsigned char *temp=(unsigned char*)_Value;[/u]
spi_buffer[SEQNR]=0;
spi_buffer[COMMAND]=0x70;
spi_buffer[LENGTH]=7;
spi_buffer[DATA]=_Mode;
spi_buffer[DATA+1]=_Adr;
spi_buffer[DATA+2]=*(temp+3);
spi_buffer[DATA+3]=*(temp+2);
spi_buffer[DATA+4]=*(temp+1);
spi_buffer[DATA+5]=*temp;
spi_buffer[DATA+6]=_Trans_Adr;
if(zlg500cmd(10)!=SPI_OK)
return SPI_ERR;
return spi_buffer[STATUS]; :roll: |
|
|
lgeorge123
Joined: 05 Dec 2004 Posts: 31
|
convert 8051 c to ccs c compiler |
Posted: Mon Jun 12, 2006 10:15 am |
|
|
original copying to ccs c compile output error message. |
|
|
guest Guest
|
|
Posted: Mon Jun 12, 2006 10:52 am |
|
|
"CCS long" and a "CCS int" is not the same to a Keil8051 or many other C Compilers on sizeof(long) / sizeof(int) !
Please use with CCS the secure way to #define INT int16 and #define LONG int32. On the next please check the "byteorder" of a 4 byte long value with CCS and C51. If ok, compile this:
unsigned char mifs_value(unsigned char _Mode,unsigned char _Adr,int32 *_Value,unsigned char _Trans_Adr)
{
unsigned char *temp;
temp=(unsigned char*)_Value;
spi_buffer[SEQNR]=0;
spi_buffer[COMMAND]=0x70;
spi_buffer[LENGTH]=7;
spi_buffer[DATA]=_Mode;
spi_buffer[DATA+1]=_Adr;
spi_buffer[DATA+2]=temp[3];
spi_buffer[DATA+3]=temp[2];
spi_buffer[DATA+4]=temp[1];
spi_buffer[DATA+5]=temp[0];
spi_buffer[DATA+6]=_Trans_Adr;
if(zlg500cmd(10)!=SPI_OK)
return SPI_ERR;
return spi_buffer[STATUS];
} |
|
|
|