Please help me understand the CAN component PIC18

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Please help me understand the CAN component PIC18

Post by QMESAR »

Hi All,
Just checking if my understanding of the CAN component is correct any help and advise is most welcome

The PIC18 ECAN as 2 Receive buffers and the CAN component seem to read 1 byte at a time from a buffer, The user should check which buffer has a new message and then read the message out byte by byte as specified by the DLC of the message

In my case I would expect 2 Messages for my CAN node (set-up filters and masks to accept these two messages, however these messages can randomly end up in RX buffer 0 or 1 there for I need to check both buffers and select which message was received read the 8 data bytes out in a loop into a Buffer(Array) for processing by the application code.
As you will see in my Flowchart i check both buffers and if the buffer is not empty I select the ID and then process (read the message ) out in a loop byte for byte into a String ( it seems a string variable and a Bate array is the same thing in FC is this true ?)

Basically the code consist of two exact same code pieces only the buffer from where it is read is different. :shock: in the picture code for Buffer 0 is shown but the exact code also exist for Buffer 1

Is this correct or is there a more intelligent way to do this ?

all help is much appreciated
Attachments
1.JPG
1.JPG (42.14 KiB) Viewed 2498 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: Please help me understand the CAN component PIC18

Post by QMESAR »

:D
It took me a while However I think I found the more intelligent way I was looking for

Checking which buffer has a new Message and then load the buffer number to a variable which I then use in the CAN read as the buffer to read this allows for only 1 set of code to handle both Buffers I will try this tomorrow

any case would be great to get some ideas from other users :D

Have good evening

Post Reply