Not applicable
Dec 01, 2015
06:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 01, 2015
06:44 PM
I have an problem in using XMC4500 CAN module. I want to use node1, P1.12 as can txd pin and P1.13 as can rxd pin.Following code is used to initialise can module
#define CAN_RX_PIN P1_13
#define CAN_TX_PIN P1_12
#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,
};
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);
/*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);
}
void CAN0_7_IRQHandler(void)
{
}
I send a message,but i can't see any waveform on txd pin on the oscilloscope. Why?
#define CAN_RX_PIN P1_13
#define CAN_TX_PIN P1_12
#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,
};
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);
/*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);
}
void CAN0_7_IRQHandler(void)
{
}
I send a message,but i can't see any waveform on txd pin on the oscilloscope. Why?
4 Replies
Dec 02, 2015
01:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 02, 2015
01:09 AM
The easiest thing is to desgin the can node with a dave app i think, and copy the generated files for CAN and the can app to your code.
I'm missing the "const CAN_NODE_t CAN_NODE_1" here.
I'm missing the "const CAN_NODE_t CAN_NODE_1" here.
Not applicable
Dec 02, 2015
02:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 02, 2015
02:39 AM
I also use DAVE4 to develop my can program. When the xmc4500 works in loopback mode,two nodes can send and receive correctly.But when the xmc4500 works in normal mode, i can't see any waveform on the CAN TXD pin on the oscilloscope. so i am very depressed. And only loopback program is offered in DAVE4,can you provided me some other can programs?
Not applicable
Dec 03, 2015
11:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 03, 2015
11:22 AM
You cant measure the TXD Pin. Connect a transceiver to your relax kit and connect a CAN device with transceiver and measure the messages.
Dec 04, 2015
12:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 04, 2015
12:39 AM
True, a CAN node on its own is not able to transmit anything. It needs to see at least one other transceiver on the bus.