I have a LM4F232-Evalkit on my desk and spent some time to make CAN interace 0 work. My problem: I configured CAN0 for PORTN, PORTF and PORTB. Out of these configurations, only CAN0 on PORTB (B4/B5) is working. For configurations on PORTN (N0/N1) and PORTF (F0/F3) I am not able to receive any CAN frames and sending (TX) is working, only after I enabled the loopback configuration in the CAN controller. I use Stellarisware to configure GPIO-pins and CAN-interface.
This configuration is working (PORTB):
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
ROM_CANIntEnable(CAN0_BASE, CAN_INT_MASTER|CAN_INT_ERROR|CAN_INT_STATUS);
ROM_GPIOPinConfigure(GPIO_PB4_CAN0RX);
ROM_GPIOPinTypeCAN(GPIO_PORTB_BASE, GPIO_PIN_4);
ROM_GPIOPinConfigure(GPIO_PB5_CAN0TX);
ROM_GPIOPinTypeCAN(GPIO_PORTB_BASE, GPIO_PIN_5);
ROM_CANInit(CAN0_BASE);
ROM_CANBitRateSet(CAN0_BASE, ROM_SysCtlClockGet(), get_bitrate());
ROM_CANIntEnable(CAN0_BASE, CAN_INT_MASTER|CAN_INT_ERROR|CAN_INT_STATUS);
ROM_CANEnable(CAN0_BASE);
This configuration is not working (PORTN):
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
ROM_CANIntEnable(CAN0_BASE, CAN_INT_MASTER|CAN_INT_ERROR|CAN_INT_STATUS);
ROM_GPIOPinConfigure(GPIO_PN0_CAN0RX);
ROM_GPIOPinTypeCAN(GPIO_PORTN_BASE, GPIO_PIN_0);
ROM_GPIOPinConfigure(GPIO_PN1_CAN0TX);
ROM_GPIOPinTypeCAN(GPIO_PORTN_BASE, GPIO_PIN_1);
ROM_CANInit(CAN0_BASE);
ROM_CANBitRateSet(CAN0_BASE, ROM_SysCtlClockGet(), get_bitrate());
ROM_CANIntEnable(CAN0_BASE, CAN_INT_MASTER|CAN_INT_ERROR|CAN_INT_STATUS);
HWREG(get_base_addr() + CAN_O_CTL) |= CAN_CTL_TEST;
HWREG(get_base_addr() + CAN_O_TST) |= CAN_TST_LBACK; // Enable loopback to see any TX messages on the bus
ROM_CANEnable(CAN0_BASE);
It seems to me that the RX-pin is not routed to the CAN0-interface internally. When I tried the PORTF configuration, I found out that the AFSEL register of PORTF was set to 0x8 instead of 0x9. When I tried to configure this register manually to 0x9 in my debugger (GDB) the value remained 0x8. When I entered 0xFF the value read back was 0xFE. Bit0 remains always 0. That would explain the behaviour of not receiving any data from the RX pin.
Question: Is there an error on my side, or is this an internal MCU error? The MCU on my eval board is a LM4F232H5QDIGA1 19AD23W G1. I've checked the errata (Rev. C), but found no related information.