Posted on:
Hi, my CodeVision AVR is doing crazy things, but okay, more probable is that I don't see my mistake... I get the following error message (latest CV-version 2.04.4a, for ATmega168P)
Error: D:\...\project_sercom.c(639), included from: project_0-1.c: function argument #1 of type 'char' is incompatible with required parameter of type 'char *' |
// function call which the error refers to: CRC_calc(*data_buf0, *datbuf0_cnt); // the used global char array: char data_buf0[DATA_BUF0_MAX]; // function: void CRC_calc(char *data_buf, unsigned char *buf_cnt) { unsigned char i = 0; unsigned char local_buf_cnt = 0; unsigned int ui_CRC = 0; char CRC_ASCII_byte[3] = { 0, 0, 0 }; local_buf_cnt = *buf_cnt; // Calculate 16bit unsigned int CRC ui_CRC = ui_CRC ^ address; for ( i = 0; i < buf_cnt; i++ ) { ui_CRC = ui_CRC ^ *(data_buf + i); if ( ( 0x0001 && ui_CRC ) == 1 ) ui_CRC = ( 0x7FFF & ( ui_CRC >> 1 ) ) ^ 0xA001; else ui_CRC = 0x7FFF & ( ui_CRC >> 1 ); } // put CRC into 3 ASCIIs: CRC_ASCII_byte[0] = 0x40 | ( 0x000F & ( ui_CRC >> 12 ) ); CRC_ASCII_byte[1] = 0x40 | ( 0x003F & ( ui_CRC >> 6 ) ); CRC_ASCII_byte[2] = 0x40 | ( 0x003F & ui_CRC ); // add the 3 CRC ASCIIs to buffer: for( i = 0; i < 3; i++ ) *(data_buf + local_buf_cnt + i) = CRC_ASCII_byte[i]; *buf_cnt = local_buf_cnt + 3; } |
somewhere else in the code the pointers work perfectly, a string (char array) is copied to a data buffer. no problems there. please help! X
Posted on:
hello x, please try this: CRC_calc(data_buf0, *datbuf0_cnt); or CRC_calc(&data_buf0[0], *datbuf0_cnt); the declaration of datbuf0_cnt is missing in your code. Tschü Dude
Posted on:
Dude! THANKS! ouch, WTF did I put the "*" into the function call... Thanks, now it works! Did I say thanks?! X