Page 1 of 3

CAN Component - Buffer

Posted: Tue May 24, 2022 9:03 am
by jay_dee
Hi, In the comments for the CAN component, it states that the Buffer parameter is currently ignored.
Is the PIC's CAN registers set to only use buffer 0? therefroe no data can get into any other buffer.
or does the component automatically check both buffers?

Thanks. Just trying to improve my CAN routines as I think I am missing some message IDs when they are put on the bus in very quick succession.
J.

Re: CAN Component - Buffer

Posted: Tue May 24, 2022 12:45 pm
by BenR
Hello,

The buffer parameter is ignored for GetRxData and GetRxDataCount macros. Both of these use the buffer from the last positive CheckRx macro call.

Are you using internal or external CAN? If it's external you could maybe try running the SPI at a faster rate or calling CheckRx more often.

If it's internal then what device are you using? Maybe we can look at adding an interrupt to let you know when a message has been received so you can collect it as it comes in.

Re: CAN Component - Buffer

Posted: Fri May 27, 2022 8:09 pm
by jay_dee
Hi, I have been going through the Microchip documents for ECAN... for the FC CAN component, does it set the ECAN to mode 0 Legacy (1 extended, 2 = FIFO) ? Thanks, J.

Re: CAN Component - Buffer

Posted: Wed Jun 01, 2022 2:30 pm
by BenR
Hello,

I beleive it's in legacy mode though I may be wrong, what device are you using and are you using internal or external and I'll do a more comprehensive check.

Re: CAN Component - Buffer

Posted: Wed Jun 01, 2022 3:46 pm
by jay_dee
Hi Ben,
Using a PIC18F2585 with internal ECAN.
thanks. J.

Re: CAN Component - Buffer

Posted: Wed Jun 01, 2022 4:51 pm
by BenR
Yes confirmed it looks like we use legacy mode on the 8-bit PIC devices.

It also looks like there are receive interrupts for buffers 0 and 1 on that device if you wanted to try and use an interrupt to catch the incoming data as it comes in. I can add the interrupt definitions to the Flowcode definition file if that would help.

Re: CAN Component - Buffer

Posted: Wed Jun 01, 2022 5:04 pm
by jay_dee
Great info Ben.

The CAN int's, That would be very much appreciated, if you get time. I've read the Datasheet and have a rough handle on the GIE, PEIE, PIR3 and PIE3 registers but Im sure you will get it right far quicker than I !! :) J.

Re: CAN Component - Buffer

Posted: Wed Jun 01, 2022 9:57 pm
by BenR
Hello,

Here's a new version of the definition file that should allow two new interrupts for CAN RX. If this works ok then I'll roll this out to the rest of the chip family.

18F2585.fcdx
(27.7 KiB) Downloaded 64 times

You'll need to place the file here, the easiest way to get there is to copy and paste the address into the address bar of your file explorer.

C:\ProgramData\MatrixTSL\FlowcodeV9\FCD\PIC

Then restart Flowcode and the new interrupts should be available to be selected.

Re: CAN Component - Buffer

Posted: Wed Jun 01, 2022 11:19 pm
by jay_dee
Thanks Ben, I'll try to get some time on this ASAP..but real work with the Race team kicks in next week and I have to poke their ECUs for LeMans, but the aim is to work on this stuff in the background. Thanks. J.

Re: CAN Component - Buffer

Posted: Fri Jun 17, 2022 1:19 pm
by jay_dee
Hi,
This is my test FC for the CAN RX Inturrupts.
In the main loop I have a (GREEN) secion to manually check for new data in Buffer 0. I used this to check that everything else is working in the FC and output.
An external CAN tool is transmitting a couple of data frames onto the bus. The CAN component settings are 'Accept all'.
Most of the other macros in the FC are just formatting a UART diagnosic output for a VT100 Emulator, for monitoring purposes.
CAN_Simple_Rx_Tests.fcfx
(65.81 KiB) Downloaded 49 times
If I run the FC with the GREEN highlighted code it all works as expected. If this code is disabled and set 'CAN RX BUF0' interrupt enabled, I get no responce.
Any thoughts appreciated. J.