XMC 4500 External CAN Communication

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

cross mob
lock attach
Attachments are accessible only for community members.
Not applicable
Trying to send a CAN message (and blink a light) only when a button is pressed, but am met with the following challenge:

After the button is first pressed, the light turns on, the message is sent, however it never stops sending.

When I release the button the light turns on, but the message is still being sent.

I am sure I don't understand the CAN API fully so I was wondering if someone could enlighten me.

Program is attached and Main.c is listed below.

Thanks,

Adam

My Main.c is as follows:

int main(void)
{
bool switch1=1;
uint32_t Status = CAN001_ERROR;
uint8_t Data[8] = {0xBC,0x11,0x22,0xA5,0xEF,0xFF,0x89,0x01};

void button__Press()
{
if(switch1==0)
{
Status = CAN001_SendDataFrame(&CAN001_Handle0,1);
//if(Status == DAVEApp_SUCCESS)
//{
IO004_SetOutputValue(IO004_Handle0,1);
}
else {
IO004_SetOutputValue(IO004_Handle0,0);

}

}
//if(switch1==1)
//{
// IO004_SetOutputValue(IO004_Handle0,0);
//CAN001_UpdateMODataRegisters(&CAN001_Handle0,1,8,Data);
//}

//}
// ... Initialises DAVE Apps configurations ...
DAVE_Init();

/* Update data value to be transmitted by Node "Request" in message object 1 (LM01) with ID 0x255 */
//CAN001_UpdateMODataRegisters(&CAN001_Handle0,1,8,Data);
/* Send Data frame with ID 0x255 on chip internal CAN bus (Loop-Back Mode) */

// ... infinite loop ...
while(1)
{
CAN001_UpdateMODataRegisters(&CAN001_Handle0,1,8,Data);
switch1 = IO004_ReadPin(IO004_Handle1);
button__Press();

}
return 0;
}
0 Likes
2 Replies
Not applicable
Was able to find the issue, I had interrupts enabled but was not using them so after sending the message the interrupt would "freeze" the program.

My next issue however is how do I send multiple messages with different frequencies? (i.e. one message is sent every 500ms, the other every 1s).

Thanks in advance.

-Adam
0 Likes
Not applicable
I am unable to receive any the message on the Relax Lite kit. I have set up a message object as a receive object but receive CAN001_MO_NOT_ACCEPTABLE when calling CAN001_ReadMsgObj.
0 Likes