MCP2515 : checkRX not working ?

Any bugs you encounter with Flowcode should be discussed here.
Post Reply
ruben123
Posts: 11
http://meble-kuchenne.info.pl
Joined: Thu Dec 10, 2020 12:17 pm
Has thanked: 6 times
Been thanked: 3 times

Flowcode v9 MCP2515 : checkRX not working ?

Post by ruben123 »

Dear,

When I run this program, it is actually quite a basic program to check whether the CheckRx function works. I check whether any messages have been received, and depending on that, I change the status of the LEDs.

I compile the program to an Arduino Nano, which is connected via software SPI to an MCP2515 module. The pins used are:

MOSI = D7

MISO = D6

CLK = D5

SS = D4

The problem I am seeing:

The CheckRx function always returns 0 (so no message is recognized as received).

Only if I change the buffers in the properties panel, for example by setting Buffer 1 to Reject All, and then send a message with a CAN analyzer, the green LED turns on and stays on.

In all other configurations, the program does not respond to the transmitted messages, even though I can clearly see in the CAN analyzer and on the oscilloscope that the messages are actually being sent.

The variable RETVAL remains unchanged, except in the specific case described above. Then, RETVAL changes once when the message is received, but afterwards the status remains stuck.

It is notable that transmitting messages in this setup works without any problems.

My question:
How is it possible that CheckRx() does not detect any reception in all other cases, even though the messages are visibly being transmitted? Why does the program only respond when Buffer 1 is set to Reject All, and why does the status then remain unchanged afterwards?
Attachments
kaart_aansturing_voedingV1.fcfx
(44.6 KiB) Downloaded 25 times

mnfisher
Valued Contributor
Posts: 1627
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 142 times
Been thanked: 758 times

Re: MCP2515 : checkRX not working ?

Post by mnfisher »

It is very difficult (I'm not going to say impossible - but) - to read anything on SPI (or i2c / UART etc) without using an interrupt.
The issue is always one of 'timing'. The 'read' needs to be at exactly the right time to catch the data.
Sending is easier - of course.

The easiest option here would be to use a chip with 2 SPI channels - although you might be able to do something by using a different CS line for the CAN component ( especially if the W5500 is mainly used to transmit data)

Martin

Post Reply