I need some help setting up my J1939 definition for CAN bit timing. I am using a PIC18LF26K80 microcontroller with an 8 MHz clock. I'm having trouble trying to figure out how to calculate the different bits for the CAN registers.
Right now in my J1939.def file I have this but it is for a 16 MHz clock
#define ECAN_RX_INTERRUPT_PRIORITY 0x00
#define ECAN_TX_INTERRUPT_PRIORITY 0x00
#define ECAN_INTERRUPT_PRIORITY (ECAN_RX_INTERRUPT_PRIORITY | ECAN_TX_INTERRUPT_PRIORITY)
#define ECAN_LEGACY_MODE J1939_TRUE
#define ECAN_EXTRA_RX_BUFFERS 3
#define ECAN_SJW 2
#define ECAN_BRP 1
#define ECAN_BRGCON1 (((ECAN_SJW-1)<<6) | (ECAN_BRP-1))
#define ECAN_SEG2PHTS 0x80
#define ECAN_SAM 0x00
#define ECAN_SEG1PH 6
#define ECAN_PRSEG 6
#define ECAN_BRGCON2 (ECAN_SEG2PHTS | ECAN_SAM | ((ECAN_SEG1PH-1)<<3) | (ECAN_PRSEG-1))
#define ECAN_WAKDIS 0x80
#define ECAN_WAKFIL 0x00
#define ECAN_SEG2PH 3
#define ECAN_BRGCON3 (ECAN_WAKDIS | ECAN_WAKFIL | (ECAN_SEG2PH-1))
I've looked in the documentation for my microcontroller and it shows how to set the bits but I still don't understand how to use that information to calculate for an 8 MHz clock.