CAN Component - Buffer

For general Flowcode discussion that does not belong in the other sections.
jay_dee
Posts: 130
http://meble-kuchenne.info.pl
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 46 times
Been thanked: 29 times

CAN Component - Buffer

Post 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.

BenR
Matrix Staff
Posts: 1707
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: CAN Component - Buffer

Post 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.

jay_dee
Posts: 130
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 46 times
Been thanked: 29 times

Re: CAN Component - Buffer

Post 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.

BenR
Matrix Staff
Posts: 1707
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: CAN Component - Buffer

Post 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.

jay_dee
Posts: 130
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 46 times
Been thanked: 29 times

Re: CAN Component - Buffer

Post by jay_dee »

Hi Ben,
Using a PIC18F2585 with internal ECAN.
thanks. J.

BenR
Matrix Staff
Posts: 1707
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: CAN Component - Buffer

Post 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.

jay_dee
Posts: 130
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 46 times
Been thanked: 29 times

Re: CAN Component - Buffer

Post 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.

BenR
Matrix Staff
Posts: 1707
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: CAN Component - Buffer

Post 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 57 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.

jay_dee
Posts: 130
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 46 times
Been thanked: 29 times

Re: CAN Component - Buffer

Post 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.

jay_dee
Posts: 130
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 46 times
Been thanked: 29 times

Re: CAN Component - Buffer

Post 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 45 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.

Post Reply