I use the RS232 to communicate between the atmega8535 microcontroller and the PC. Because an RS232 is very vulnerable to EMI, I added a checksum using the CRC-CCITT function in the CRC16.h file from the AVR-libc library.
To be able to communicate, the microcontroller and the PC must calculate the CRC-checksum exactly the same way. I implemented the crc-ccitt algorithm in C given in the avr-libc documentation in Java, but is doesn't work. I doubt if it even works in C. So for people who encounter the same problem, I give my WORKING java-code-snippet here:
byte a,c,k,h; a=(byte)(((CRC_value&0x00FF)) ^ data); c=(byte)((a<<4) ^ a); k=(byte)(((c<<3)) ^ (CRC_value>>8) ^ ((c&0xFF)>>4)); h=(byte)(c ^ ((c&0xFF)>>5)); CRC_value=(char)((((char)h)<<8)|(k&0xFF));