Lemosek
Joined: 15 Oct 2011 Posts: 36
|
LIN bus |
Posted: Tue Oct 25, 2011 3:05 pm |
|
|
Hello,
I have some problem with lin bus driver. Is someone use this driver ??
I think some function have mistakes, for example:
Code: |
#bit ID_Parity_error = Errorflag.0
#bit bit_error = Errorflag.1
#bit CRC_error = Errorflag.2
#bit data_received = Errorflag.3
#bit addr_match = Errorflag.4
|
Code: |
/*
void linbus_verify_checksum(byte* databytes, int8 message_length)
This function will verify the checksum of the data received
Call this function after read_data_packet()
PARAMS databytes: Received Data
PARAMS message_length: Length of message
RETURNS: none
This function will set the CRC_error bit in Errorflag if it detect checksum error
*/
void linbus_verify_checksum(byte* databytes, int8 message_length)
{
int CRC, CRC_actual;
CRC_actual = getc();
CRC = linbus_calculate_checksum(&databytes[0], message_length);
if(CRC_actual==CRC)
CRC_error =0;
else
CRC_error =0; // i think here should be 1
}
|
I built the circuit, pic16f690 and mcp2003 with 8Mhz crystal for master and pic16f690, mcp2003 with intRC 8MHz. I tried testing code from example but this code don't working.
My complier is 4.120.
Maybe someone have working code ?? for lin bus.
Best regards |
|