Page 2 of 3

Re: CAN Component - Buffer

Posted: Fri Jun 17, 2022 2:04 pm
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.

Re: CAN Component - Buffer

Posted: Fri Jun 17, 2022 2:39 pm
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 53 times
J.

Re: CAN Component - Buffer

Posted: Tue Jun 28, 2022 12:42 pm
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.

Re: CAN Component - Buffer

Posted: Mon Jul 11, 2022 12:26 pm
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.

Re: CAN Component - Buffer

Posted: Mon Jul 11, 2022 3:14 pm
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);

Re: CAN Component - Buffer

Posted: Mon Jul 11, 2022 3:36 pm
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 ?

Re: CAN Component - Buffer

Posted: Mon Jul 11, 2022 4:47 pm
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;

Re: CAN Component - Buffer

Posted: Mon Jul 11, 2022 8:12 pm
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.

Re: CAN Component - Buffer

Posted: Tue Jul 12, 2022 9:19 am
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.

Re: CAN Component - Buffer

Posted: Tue Jul 12, 2022 12:24 pm
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.