CAN Component - Buffer

BenR
Matrix Staff
Posts: 1106
http://meble-kuchenne.info.pl
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 281 times
Been thanked: 377 times

Re: CAN Component - Buffer

Post by BenR »

Hello,

You probably need to call the CheckRx macro inside the interrupt macro as this does things like copies the data from the can registers into a local buffer. Hopefully that's all that is required but maybe not. If so then let us know and I'll dig in further.

jay_dee
Posts: 97
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 28 times
Been thanked: 27 times

Re: CAN Component - Buffer

Post by jay_dee »

Thanks Ben,
As suggested, I've just tried that. No change.
CAN_Simple_Rx_Tests_V1-1.fcfx
(66.09 KiB) Downloaded 15 times
J.

jay_dee
Posts: 97
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 28 times
Been thanked: 27 times

Re: CAN Component - Buffer

Post by jay_dee »

Any Thoughts?
I should be able to clear some bench time next week to progress this if there is anything to test. Thanks, John.

jay_dee
Posts: 97
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 28 times
Been thanked: 27 times

Re: CAN Component - Buffer

Post by jay_dee »

Hi, As suggested I tried inserting the CheckRx macro but this did not change the behaviour, the interrupt still does not run.
Any further thoughts?
Or could you supply the interrupt code you are using and I'll try to play around with it as a custom interrupt.
I tried making my own custom but its on the endge of my understanding. :)
Thanks, J.

BenR
Matrix Staff
Posts: 1106
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 281 times
Been thanked: 377 times

Re: CAN Component - Buffer

Post by BenR »

Hello,

Here's the current interrupt defined in the definition file you can try and play around with. Not really sure what else to suggest at the moment. It's too hot today 8-)

Handler

Code: Select all

if (ts_bit(PIR3, RXB0IF) && ts_bit(PIE3, RXB0IE))
{
    FCM_%n();
    cr_bit(PIR3, RXB0IF);
}
Enable

Code: Select all

st_bit(INTCON, PEIE);
st_bit(PIE3, RXB0IE);
Disable

Code: Select all

cr_bit(PIE3, RXB0IE);

jay_dee
Posts: 97
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 28 times
Been thanked: 27 times

Re: CAN Component - Buffer

Post by jay_dee »

I assume
ts_Bit = test Bit.
st_Bit = Set bit
cr=Bit = Clear bit
and these are little macros dinfined in the compiler or FC ?

BenR
Matrix Staff
Posts: 1106
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 281 times
Been thanked: 377 times

Re: CAN Component - Buffer

Post by BenR »

Hello,

Yes that's correct and they are defined by Flowcode as follows.

#define st_bit(var,bitno) CAL_APPEND(var, bits.bitno) = 1
#define cr_bit(var,bitno) CAL_APPEND(var, bits.bitno) = 0
#define ts_bit(var,bitno) (CAL_APPEND(var, bits.bitno))

so

Code: Select all

cr_bit(PIR3, RXB0IF);
becomes the following when using PICs

Code: Select all

PIR3bits.RXB0IF = 0;

jay_dee
Posts: 97
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 28 times
Been thanked: 27 times

Re: CAN Component - Buffer

Post by jay_dee »

Ah... I may have missunderstood.
If I place the CheckRx macro in the main, then the interupt will run.
I assumed it would have to be in the Interrupt routine.
Does this make sense that it works with the CheckRx macro in the main loop?
J.

jay_dee
Posts: 97
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 28 times
Been thanked: 27 times

Re: CAN Component - Buffer

Post by jay_dee »

Just checked last nights work.
The CAN interrupt will only run if CheckRx is placed in the main loop.
If the main loop is slowed down by a 500ms Delay, the interrupt will only run at this rate.
So I am fairly sure Check Rx is toggling some bit thus activating or deactivating a larger part of the CAN periferal.

Are you happy to forward the routines behind CheckRX ?
J.

BenR
Matrix Staff
Posts: 1106
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 281 times
Been thanked: 377 times

Re: CAN Component - Buffer

Post by BenR »

Hello,

Ok that's interesting, I wonder why. The code for the CheckRx can be found here C:\ProgramData\MatrixTSL\FlowcodeV9\CAL\PIC\PIC_CAL_CAN.c around line 382.

Post Reply