Other Parts Discussed in Thread: TM4C1231H6PZ
Hi, When I try to enable CAN1(SYSCTL_PERIPH_CAN1) It gets stucked waiting for the peripheral to be ready, if I run the same for the CAN0(SYSCTL_PERIPH_CAN0) it works fine, also SysCtlPeripheralPresent(SYSCTL_PERIPH_CAN1); return "0".
void InitCAN1(void){
//
// For this example CAN0 is used with RX and TX pins on port E4 and E5.
// GPIO port E needs to be enabled so these pins can be used.
//
// SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//
// Configure the GPIO pin muxing to select CAN0 functions for these pins.
// This step selects which alternate function is available for these pins.
//
GPIOPinConfigure(GPIO_PA0_CAN1RX);
GPIOPinConfigure(GPIO_PA1_CAN1TX);
//
// Enable the alternate function on the GPIO pins. The above step selects
// which alternate function is available. This step actually enables the
// alternate function instead of GPIO for these pins.
//
GPIOPinTypeCAN(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// The GPIO port and pins have been set up for CAN. The CAN peripheral
// must be enabled.
//
uint32_t present;
present = SysCtlPeripheralPresent(SYSCTL_PERIPH_CAN1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN1);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_CAN1))//new
{
}
//
// Initialize the CAN controller
//
CANInit(CAN1_BASE);
//
// Set up the bit rate for the CAN bus. This function sets up the CAN
// bus timing for a nominal configuration. You can achieve more control
// over the CAN bus timing by using the function CANBitTimingSet() instead
// of this one, if needed.
// In this example, the CAN bus is set to 500 kHz.
//
CANBitRateSet(CAN1_BASE, SysCtlClockGet(), 250000);
//
// Enable interrupts on the CAN peripheral. This example uses static
// allocation of interrupt handlers which means the name of the handler
// is in the vector table of startup code.
//
CANIntRegister(CAN1_BASE, CANIntHandler);
CANIntEnable(CAN1_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);
//
// Enable the CAN interrupt on the processor (NVIC).
//
IntEnable(INT_CAN1);
//
// Enable the CAN for operation.
//
CANRetrySet(CAN1_BASE, 0);//desactiva auto retransmission
CANEnable(CAN1_BASE);
}