AnsweredAssumed Answered

STM32F4 CAN data problem

Question asked by van_wyk.herman on Jul 9, 2013
Latest reply on Oct 21, 2013 by van_wyk.herman
Hi all,

I am using the CAN interface on the STM3240G-EVAL for a CanOpen implementation.
All works fine up until the point where I need to transfer data via CanOpen PDOs which are more than 6 bytes in length. The last 2 bytes are always corrupt.
I performed debugging up to the point where the data values are loaded into the TDLR and TDHR registers and all is fine. The receiving node however receives all the data correctly except for the lat 2 bytes that are random values and not what I sent. These values also change with every transmission and there is also no pattern, the values are random. I also used a PEAK CAN device to listen on the bus to ensure that the problem is not on my receiving node software. The PEAK CAN device confirms the last 2 bytes being corrupt.
I now don't know what can cause this. Here is the configuration I use to set up the CAN bus on all my devices. 
Can anyone give me an idea as to what might be wrong or what I might be missing in the configuration?

01./* PCLK = 42MHz */ /* 10kbps */
02.can_struct.CAN_Mode = CAN_Mode_Normal;
03.can_struct.CAN_Prescaler = 199;
04.can_struct.CAN_BS1 = 13;
05.can_struct.CAN_BS2 = 5;
06.can_struct.CAN_SJW = 3;
07.can_struct.CAN_ABOM = DISABLE;
08.can_struct.CAN_TTCM = ENABLE;
09.can_struct.CAN_AWUM = DISABLE;
10.can_struct.CAN_NART = ENABLE;
11.can_struct.CAN_RFLM = ENABLE;
12.can_struct.CAN_TXFP = ENABLE;
13. 
14./* Attempt to initialize the CAN bus until the bus is ready */
15.do
16.{
17.  retstat = CAN_Init(CAN1, &can_struct);
18.}
19.while (retstat != CAN_InitStatus_Success);
20. 
21.if (retstat == CAN_InitStatus_Failed)
22.{
23.  return(CO_E_INIT_HARD_RES_ACTIVE);
24./* end "if (retstat == CAN_InitStatus_Failed)" */
25. 
26./* initialize filter structure for use in filter banks */
27.can_filt.CAN_FilterActivation = ENABLE;
28.can_filt.CAN_FilterIdHigh = 0xFFFE;
29.can_filt.CAN_FilterIdLow = 1;
30.can_filt.CAN_FilterMaskIdHigh = 0xFFFE;
31.can_filt.CAN_FilterMaskIdLow = 1;
32.can_filt.CAN_FilterMode = CAN_FilterMode_IdMask;
33.can_filt.CAN_FilterNumber = 1;
34.can_filt.CAN_FilterScale = CAN_FilterScale_16bit;
35. 
36.can_filt.CAN_FilterFIFOAssignment = CAN_Filter_FIFO0;
37. 
38./* assign half of filter banks to FIFO 0 */
39.for (loop = 0; loop < (14 / 2); loop++)
40.{
41.  can_filt.CAN_FilterNumber = loop;
42. 
43.  CAN_FilterInit(&can_filt);
44./* end "for (loop = 0; loop < (14 / 2); loop++)" */
45. 
46.can_filt.CAN_FilterFIFOAssignment = CAN_Filter_FIFO1;
47. 
48./* assign half of filter banks to FIFO 1 */
49.for (loop = (14 / 2); loop < 14; loop++)
50.{
51.  can_filt.CAN_FilterNumber = loop;
52. 
53.  CAN_FilterInit(&can_filt);
54./* end "for (loop = (14 / 2); loop < 14; loop++)" */



Thanks,

H

Outcomes