Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7771

SDK • Re: Trouble using spi1 with MCP2515

$
0
0
Ah, sorry, I missed that the problem was now only the bitrate.

If we convert your CNF registers to mathematical variables, then:

Code:

CNF1 = 0x00CNF2 = 0x91CNF3 = 0x81
becomes:

Code:

sjw          = 1t_bit        = t_sync_seg + t_prop_seg + t_ps1 + t_ps2 = 8t_sync_seg   = 1t_prop_seg   = 2t_ps1        = 3t_ps2        = 2sample_point = (t_sync_seg + t_prop_seg + t_ps1) / t_bit = 75%
As you said, you are using a sample point of 75%. But the MCP2515 datasheet (4th paragraph in 5.3 Programming Time Segments) says:
Typically, the sampling of the bit should take place at about 60-70% of the bit time, depending on the system parameters.
If you instead put the sample point at ~62%, using these variables:

Code:

sjw          = 1t_bit        = t_sync_seg + t_prop_seg + t_ps1 + t_ps2 = 8t_sync_seg   = 1t_prop_seg   = 1t_ps1        = 3t_ps2        = 3sample_point = (t_sync_seg + t_prop_seg + t_ps1) / t_bit = 62.5%
You will land in the middle-ish of the recommended sample point percentage.

When you only have 8 TQs to work with and the sample point is placed too close or too far away, you can get synchronization problems, which could make the MCP2515 send the bits at a higher bitrate.

In closing, try using these CNF values instead:

Code:

CNF1 = 0x00CNF2 = 0x90CNF3 = 0x82

Statistics: Posted by rzetterberg — Thu May 28, 2026 8:18 pm



Viewing all articles
Browse latest Browse all 7771

Latest Images

Trending Articles



Latest Images