Page 1 of 1

PIC CCP wont run if Internal CAN Enabled

Posted: Fri May 30, 2025 10:10 am
by jay_dee
Hi,
Using 18F PIC CCP and ECCP periferals, in capture mode and Timer3, in PIC 18F4680 and 18F2580.
ECCP works without issue. (The second ECCP module is only available on the higher pin count devices)

However, If the CAN Component is initaialised in internal mode, no external signal will trigger the interupt of CCP.

Attached is flowcode in a working state. CAN is set to External.
If this is changed to internal, the Interupt will never be called.
CCP_Capture_Test_PIC18F4680.fcfx
(49.63 KiB) Downloaded 129 times
I am not sure if this is due to some sharing of TMR3.
Or something to do with CAN Rx also being linked to the interrupts.

All bit of pain, as I'm quite commited to a comercial project requiring both CCP, ECCP ports + CAN. :)
(My CAN routine is not currently using any Interupts but I would like to do so in the future if possible. )
Any thoughs FC Team ?

Re: PIC CCP wont run if Internal CAN Enabled

Posted: Fri May 30, 2025 11:46 am
by BenR
Hello,

I've just had a look and the internal CAN doesn't seem to use Timer 3 or CCP and so shouldn't cause an issue.

If you need to have a look at the CAN code then it's available here. Just copy and paste the address into the file browser address bar.

C:\ProgramData\MatrixTSL\FlowcodeV10\CAL\PIC

Then open the PIC_CAL_CAN.c in a text editor.

I wonder if it's a known silicone bug. You could maybe check the Errata documents here for potential known issues and workarounds.
https://www.microchip.com/en-us/product ... umentation

Seems to be a lot in there regarding the ECCP module.

Re: PIC CCP wont run if Internal CAN Enabled

Posted: Fri May 30, 2025 1:50 pm
by jay_dee
Hmm, OK thanks for checking Ben, I check the extra docs. I think I'll also try to monitor the register values relating to the interrupts, see what's changing when the CAN initialises. J.

Re: PIC CCP wont run if Internal CAN Enabled

Posted: Thu Jun 12, 2025 9:58 am
by jay_dee
Hi,
short update.
I monitored the CIOCON register...there is something setting the CANCAP bit, this enabled CAN message recieve interupt and stops triggers from RC2 to the CCP1.
I tried to manually set the CANCAP bit to 0, but it did not seem stable and bit was getting reset to 1 somehow.
I tried to write my own CAN INIT but it was also not stable...

as I work around I'm looking at ways of avoiding CCP1. J.

Re: PIC CCP wont run if Internal CAN Enabled

Posted: Tue Jun 17, 2025 1:39 pm
by medelec35
Hello
I have noticed that CAN.CAL FC_CAL_Internal_CAN_Init sets CANCAP to 1:
CALFUNCTION(void, FC_CAL_Internal_CAN_Init_, (void))
{
#if (MX_CAN_CHANNEL_X == 1)
//configure CAN I/O
CIOCON = 0x30;

and
FC_CAL_Internal_CAN_Uninit sets it to 0:
CALFUNCTION(void, FC_CAL_Internal_CAN_Uninit_, (void))
{
#if (MX_CAN_CHANNEL_X == 1)
CANCON = 0x00;
CANSTAT = 0x00;
#endif

The CAN component only has Init and not Uninit
If want to clear CANCAP and possibly might not even work?
What you could try is a add the CAN CAL component then before you want to use CCP1, add a CAL unInit.
Before using CAN again you will need to run either CAN internal initialise or CAN CAL Init.

If it does not work, what about using CCP2 instead?