CodeVision AVR: pointer type problem

OP #1513948
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
Guest
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

Reply

A question of your own? This thread is over 16 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.