Changing CAN receiver id

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

cross mob
Anonymous
Not applicable

How do i change the id of a particular receiving filter in CAN through code itself? The device i am using is psoc5lp.

   

 

   

Thank you

0 Likes
1 Reply
harshadap_76
Employee
Employee
First like received

Hi,

   

You need to use AMR and ACR registers to modify the Rx ID dynamically.

   

Kindly have a look at the following code:

   

 

   

void change_set_value_id(void)
{
  
uint8 result = CAN_FAIL;
uint32 temp_amr;
uint32 temp_acr;
  
   
temp_amr = ((uint32)0x0u << 21u) | ((uint32)0x3FFFFu << 3u); /* obtain necessary value to put in AMR */
temp_acr = ((uint32)0x110u << 21u) | ((uint32)0x3FFFFu << 3u); /* obtain necessary value to put in ACR*/
 /*0x110 is new ID, you can assign your own ID */

   

if (CAN_RXRegisterInit((reg32 *)&CAN_RX[1].rxamr, temp_amr) == CYRET_SUCCESS)
{
if (CAN_RXRegisterInit((reg32 *)&CAN_RX[1].rxacr, temp_acr) == CYRET_SUCCESS)
{
result = CYRET_SUCCESS;
}
}
if (result == CAN_FAIL)
{
/* error */
}

   

}

   

Please refer PSoC 5LP architecture and register TRM for more details:

   

http://www.cypress.com/file/123561/download

   

http://www.cypress.com/file/136211/download

   

Hope this helps.

   

Please feel free to update for any query.

   

Regards

   

Harshada

0 Likes