XMC4500 CAN module

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Recently I was using XMC4500 and i have a problem in using can module.According to the loopback example code provided by Infineon,i develop my program. I need use P1.12 and P1.13 pins as CAN pins,these pins belong to the node1. Following code is used to initialise two pins.

#define CAN_RX_PIN P1_13
#define CAN_TX_PIN P1_12


XMC_GPIO_CONFIG_t can_tx =
{
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2,
.output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM
};

XMC_GPIO_CONFIG_t can_rx =
{
.mode = XMC_GPIO_MODE_INPUT_TRISTATE
};



XMC_GPIO_Init(CAN_TX_PIN,&can_tx);
XMC_GPIO_Init(CAN_RX_PIN,&can_rx);


Following code is used to initialise CAN module


#define CAN_FREQUENCY 120000000


/*CAN message= CAN_MO4 */
XMC_CAN_MO_t CAN_message_4 =
{
.can_mo_ptr = CAN_MO4,
.can_priority = XMC_CAN_ARBITRATION_MODE_IDE_DIR_BASED_PRIO_2,
.can_identifier = 0xFF,
.can_id_mask= 0xFF,
.can_id_mode = XMC_CAN_FRAME_TYPE_EXTENDED_29BITS,
.can_ide_mask = 1,
.can_data_length = 8,
.can_data = {0x01234567, 0x89ABCDEF},
.can_mo_type = XMC_CAN_MO_TYPE_TRANSMSGOBJ
};

void CAN_INIT(void)
{

/*CAN Bit time*/
XMC_CAN_NODE_NOMINAL_BIT_TIME_CONFIG_t baud =
{
.can_frequency = CAN_FREQUENCY,
.baudrate = 100000,
.sample_point = 8000,
.sjw = 1,
};


/*Configure CAN Module*/
XMC_CAN_Init(CAN,CAN_FREQUENCY);

/*Configure CAN Node baudrate*/
XMC_CAN_NODE_NominalBitTimeConfigure(CAN_NODE1,&baud);

/*NODE 1 initialization*/
XMC_CAN_NODE_EnableConfigurationChange(CAN_NODE1);

/*XMC_CAN_NODE_EnableLoopBack(CAN_NODE1);*/


XMC_CAN_NODE_SetReceiveInput(CAN_NODE1,XMC_CAN_NODE_RECEIVE_INPUT_RXDCC);
XMC_CAN_NODE_DisableConfigurationChange(CAN_NODE1);
XMC_CAN_NODE_ResetInitBit(CAN_NODE1);


XMC_CAN_MO_EnableEvent(&CAN_message_4,XMC_CAN_MO_EVENT_TRANSMIT);
XMC_CAN_MO_SetEventNodePointer(&CAN_message_4, XMC_CAN_MO_POINTER_EVENT_TRANSMIT, 7);


XMC_CAN_AllocateMOtoNodeList(CAN, 1, 4);

/*Enable nvic node*/
NVIC_EnableIRQ(CAN0_7_IRQn);

XMC_CAN_MO_Config(&CAN_message_4);

XMC_CAN_MO_Transmit(&CAN_message_4);
}

According to the code,i transmit a message.But on the oscilloscope, I did not see any waveform on pin1.12.



Can you help me?
If you have some can code,please send these code to 594373280@qq.com.

Thanks
0 Likes
0 Replies