A little update on CAN reception, in fact only 1 channel works at a time. We have both channels connected to the CAN network (quite low load) and it appears there are some issues with CAN1. Often it just does not generate the interrupt. It's not happens every time but occurs randomly after reset, very confusing. Most strange, if CAN1 gets the interrupt then CAN0 stops going into interrupt routine. And I don't see how possible both channels can interact. Also, we've noticed in the LPC18xx Errata some hardware issues with CAN1 on LPC185x, here it is:
Problem:
On the LPC185x flash-based devices, there is an issue with the C_CAN controller AHB bus address decoding that applies to both C_CAN controllers. It affects the C_CAN controllers when peripherals on the same bus are used. Writes to the ADC, DAC, I2C, and I2S peripherals can update registers in the C_CAN controller. Specifically, writes to I2C0, MCPWM, and I2S can affect C_CAN1. Writes to I2C1, DAC, ADC0, and ADC1 can affect C_CAN0. The spurious C_CAN controller writes will occur at the address offset written to the other peripherals on the same bus. For example, a write to ADC0 CR register which is at offset 0 in the ADC, will result in the same value being written to the C_CAN0 CNTL register which is at offset 0 in the C_CAN controller. Writes to the C_CAN controller will not affect other peripherals.
And as you can imagine, our dev board has the LPC1857...also this project uses I2C0 and according to UM10430 user's manual :
Remark: Use of C_CAN controller excludes operation of all other peripherals connected\to the same bus bridge. See the LPC18xx errata.
Could you please confirm if this issue is not present on lower series - LPC183x and LPC182x?
Here is again our updated CAN init function (I realized there are 2 different clock domains for CAN0 and CAN1 so there is an extra Chip_Clock_SetBaseClock(CLK_BASE_APB1, CLKIN_IDIVC, true, false) call compared to example.
void CAN_init(void)
{
//Pinmux LPC_C_CAN0
Chip_SCU_PinMuxSet(0x3, 1, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC2)); /* CAN RD */
Chip_SCU_PinMuxSet(0x3, 2, (SCU_MODE_INACT | SCU_MODE_FUNC2)); /* CAN TD */
//Pinmux LPC_C_CAN1
Chip_SCU_PinMuxSet(0x1, 18, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC5)); /* CAN RD */
Chip_SCU_PinMuxSet(0x1, 17, (SCU_MODE_INACT | SCU_MODE_FUNC5)); /* CAN TD */
Chip_Clock_SetBaseClock(CLK_BASE_APB1, CLKIN_IDIVC, true, false);
Chip_Clock_SetBaseClock(CLK_BASE_APB3, CLKIN_IDIVC, true, false);
Chip_CCAN_Init(LPC_C_CAN0);
Chip_CCAN_SetBitRate(LPC_C_CAN0, CAN_BAUDRATE);
Chip_CCAN_EnableTestMode(LPC_C_CAN0);
Chip_CCAN_ConfigTestMode(LPC_C_CAN0, CCAN_TEST_BASIC_MODE);
Chip_CCAN_EnableInt(LPC_C_CAN0, (CCAN_CTRL_IE | CCAN_CTRL_SIE | CCAN_CTRL_EIE));
Chip_CCAN_Init(LPC_C_CAN1);
Chip_CCAN_SetBitRate(LPC_C_CAN1, CAN_BAUDRATE);
Chip_CCAN_EnableTestMode(LPC_C_CAN1);
Chip_CCAN_ConfigTestMode(LPC_C_CAN1, CCAN_TEST_BASIC_MODE);
Chip_CCAN_EnableInt(LPC_C_CAN1, (CCAN_CTRL_IE | CCAN_CTRL_SIE | CCAN_CTRL_EIE));
NVIC_EnableIRQ(C_CAN0_IRQn);
NVIC_EnableIRQ(C_CAN1_IRQn);
}