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

cross mob
Bandarikarthik
Level 3
Level 3
25 replies posted 100 sign-ins First like given

Hello  all,

I working on XMC1403MCU on CAN. I am facing the problem while Receive buffer is clearing 

I am using CAN BUS ANALYSER and transmitting the data to the XMC1403 CAN peripheral when I debugging  I can see the data in receive buffer of CAN (CAN_NODE_0_LMO_02.can_data_byte[0])

suppose this is condition is when I an not clearing the Buffer with this for loop 

/*for(int l=0;l<7;l++)
{
CAN_NODE_0_LMO_02.can_data_byte[l]=0;
}*/

After receiving the 8 bytes data to another Array  uint8_t dummycan_data_arr[8] I Am Clearing the Data in (CAN_NODE_0_LMO_02.can_data_byte[0]) 

but  so when I do this my (CAN_NODE_0_LMO_02.can_data_byte[0])  all 8 bytes are filled with zeros 

even though when I send the DATA from Analyser  while debugging the (CAN_NODE_0_LMO_02.can_data_byte[0])  are

coming zeros 

In main function 

{

CAN_Recieve();
Delaysec(1);
if(dummycan_data_arr[0] == 1)
{
CAN_SendData();

}

}

/**********************************************************/

 

void CAN_SendData()

{


uint8_t can_send_data[8];
uint8_t *can_send_datap;
uint16_t FCData[4];

FCData[0] = 54;
FCData[1] = 0;
FCData[2] = 0;
FCData[3] = 0;


//id 0x1812F400
can_send_data[0] = (FCData[0]>>8)&0xFF;
can_send_data[1] = (FCData[0]>>0)&0xFF;


can_send_data[2] = (FCData[1]>>8)&0xFF;
can_send_data[3] = (FCData[1]>>0)&0xFF;
can_send_data[4] = (FCData[2]>>8)&0xFF;
can_send_data[5] = (FCData[2]>>0)&0xFF;
can_send_data[6] = (FCData[3]>>8)&0xFF;
can_send_data[7] = (FCData[3]>>0)&0xFF;


can_send_datap = can_send_data;

CAN_NODE_MO_UpdateID(CAN_NODE_0.lmobj_ptr[0], 0x1812F400);
CAN_NODE_MO_UpdateData(CAN_NODE_0.lmobj_ptr[0],can_send_datap);
CAN_NODE_MO_Transmit(HandlePtr1->lmobj_ptr[0]);

 

status = CAN_NODE_GetStatus(HandlePtr1);

if (status & XMC_CAN_NODE_STATUS_TX_OK)
{
//Clear the transmit OK flag
CAN_NODE_ClearStatus(HandlePtr1, XMC_CAN_NODE_STATUS_TX_OK);

}

}

Problem is am continuosly receiving the data in Analyser if I Tx only once from  CAN bus analyser 

Regards,

 karthik

 

 

 

 

Bandari Karthik Kumar
0 Likes
1 Solution
Alakananda_BG
Moderator
Moderator
Moderator
50 likes received 250 sign-ins 250 replies posted

Hi @Bandarikarthik ,

We are glad to hear that after the code is updated like below you are able to receive the data.

while(1U)
{
CAN_Recieve();
Delaysec(1);

if(CAN_NODE_0_LMO_02.can_mo_ptr->MOSTAT & (1<<3))
CAN_SendData();

}

Regards,

Alakananda

View solution in original post

0 Likes
4 Replies
Alakananda_BG
Moderator
Moderator
Moderator
50 likes received 250 sign-ins 250 replies posted

Hi @Bandarikarthik ,

The program flow and the problem statement is not clear for us. We see CAN_Recieve(); called only once, not sure what this does exactly. We are not sure about the code implementation also.

"Problem is am continuously receiving the data in Analyzer if I Tx only once from CAN bus analyzer " - This statement is also not clear can you please elaborate this statement.

Can you please give us more clear description of the issue.

You can also refer to XMC CAN code examples from the below link.

Regards,

Alakananda
0 Likes
Bandarikarthik
Level 3
Level 3
25 replies posted 100 sign-ins First like given

@Alakananda_BG 

Thank you for your response!!!  while posting the thread 

I have missed while statement in code please find below main code 

In main function 

{

while(1){

CAN_Recieve();
Delaysec(1);
if(dummycan_data_arr[0] == 1)
{
CAN_SendData();

}

}

}

Bandari Karthik Kumar
0 Likes
Alakananda_BG
Moderator
Moderator
Moderator
50 likes received 250 sign-ins 250 replies posted

Hi @Bandarikarthik ,

We are glad to hear that after the code is updated like below you are able to receive the data.

while(1U)
{
CAN_Recieve();
Delaysec(1);

if(CAN_NODE_0_LMO_02.can_mo_ptr->MOSTAT & (1<<3))
CAN_SendData();

}

Regards,

Alakananda
0 Likes

Hello@Alakananda_BG  

yes its working fine !!

Bandari Karthik Kumar
0 Likes