EmbDev.net

Forum: µC & Digital Electronics CodeVision AVR: pointer type problem


von X- R. (x-rocka)


Rate this post
useful
not useful
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)
1
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 *'
1
// function call which the error refers to:
2
CRC_calc(*data_buf0, *datbuf0_cnt);
3
4
// the used global char array:
5
char data_buf0[DATA_BUF0_MAX];
6
7
// function:
8
void CRC_calc(char *data_buf, unsigned char *buf_cnt)
9
{
10
  unsigned char i = 0;
11
  unsigned char local_buf_cnt = 0;
12
  unsigned int ui_CRC = 0;
13
  char CRC_ASCII_byte[3] = { 0, 0, 0 };
14
15
  local_buf_cnt = *buf_cnt;
16
17
  // Calculate 16bit unsigned int CRC
18
  ui_CRC = ui_CRC ^ address;
19
  for ( i = 0; i < buf_cnt; i++ )
20
  {
21
    ui_CRC = ui_CRC ^ *(data_buf + i);
22
    if ( ( 0x0001 && ui_CRC ) == 1 ) ui_CRC = ( 0x7FFF & ( ui_CRC >> 1 ) ) ^ 0xA001;
23
    else ui_CRC = 0x7FFF & ( ui_CRC >> 1 );
24
  }
25
26
  // put CRC into 3 ASCIIs:
27
  CRC_ASCII_byte[0] = 0x40 | ( 0x000F & ( ui_CRC >> 12 ) );
28
  CRC_ASCII_byte[1] = 0x40 | ( 0x003F & ( ui_CRC >> 6 ) );
29
  CRC_ASCII_byte[2] = 0x40 | ( 0x003F & ui_CRC );
30
31
  // add the 3 CRC ASCIIs to buffer:
32
  for( i = 0; i < 3; i++ ) *(data_buf + local_buf_cnt + i) = CRC_ASCII_byte[i];
33
  *buf_cnt = local_buf_cnt + 3;
34
}

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

von 12er Dude (Guest)


Rate this post
useful
not useful
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

von X- R. (x-rocka)


Rate this post
useful
not useful
Dude!

THANKS! ouch, WTF did I put the "*" into the function call...

Thanks, now it works!

Did I say thanks?!

X

von SIna (Guest)


Rate this post
useful
not useful
What does this error message mean? " ']' not expected "
Tnx

von bracket (Guest)


Rate this post
useful
not useful
The balance of braces is odd.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.