hello, I'm receiving a char array consist of 8 characters, what I want to do is find the number of set bits in that array and then send it(total number) as a character to the transmitter so he can check, data is transmitted using serial port(RS232), where processing of data is done by DE0 FPGA.I've tried to use TestBit but the compiler doesn't know this function(I added #include "bit-manipulation.h" but it doesn't recognize this either) If any one can help me at that would be great .
-- the code of my project:
filed = open( "/dev/uart_0", O_RDWR );
if (filed < 0){
printf("the port can't be opened \n");
}
else {
while(1){
while(1){
read (filed, &arr[0],1);
if (arr[0] == 0x1F)
break;
}
for (i=1; i<7; i++) {
read (filed, &arr[i],1);
}
IOWR_ALTERA_AVA LON_PIO_DATA(LO AD1_BASE, 1);
IOWR_ALTERA_AVA LON_PIO_DATA(M_ BASE,((arr[1])+(arr[2]<<8)));
IOWR_ALTERA_AVA LON_PIO_DATA(E_ BASE,(arr[3]));
IOWR_ALTERA_AVA LON_PIO_DATA(G_ BASE,((arr[5])+(arr[6]<<8)));
IOWR_ALTERA_AVA LON_PIO_DATA(LO AD1_BASE, 0);
for(k=0;k<10000 ; k++){}
y = IORD_ALTERA_AVA LON_PIO_DATA(R_ BASE);
c=(unsigned char) y;
write(filed, &c,1);
}
}
}
return 0;
}
-- the code of my project:
filed = open( "/dev/uart_0", O_RDWR );
if (filed < 0){
printf("the port can't be opened \n");
}
else {
while(1){
while(1){
read (filed, &arr[0],1);
if (arr[0] == 0x1F)
break;
}
for (i=1; i<7; i++) {
read (filed, &arr[i],1);
}
IOWR_ALTERA_AVA LON_PIO_DATA(LO AD1_BASE, 1);
IOWR_ALTERA_AVA LON_PIO_DATA(M_ BASE,((arr[1])+(arr[2]<<8)));
IOWR_ALTERA_AVA LON_PIO_DATA(E_ BASE,(arr[3]));
IOWR_ALTERA_AVA LON_PIO_DATA(G_ BASE,((arr[5])+(arr[6]<<8)));
IOWR_ALTERA_AVA LON_PIO_DATA(LO AD1_BASE, 0);
for(k=0;k<10000 ; k++){}
y = IORD_ALTERA_AVA LON_PIO_DATA(R_ BASE);
c=(unsigned char) y;
write(filed, &c,1);
}
}
}
return 0;
}
Comment