cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Anonymous
Not applicable

Dear community,

   

I would like to know whether it is possible to get direct access to a CAN message after retrieval.

   

I read through the manuals and realized that PSoC stores information on received messages in different registers (CMD, ID, DH, DL, AMR, ACR, AMRD, ACRD). What I am searching for is direct access to every bit of a received CAN message like defined in the CAN 2.0 A standard:

   

Start | Identifier | RTR | IDE | r0 | DLC | Data | CRC | ACK | EOF+IFS

   

 

   

Thanks in advance!

7 Replies
Anonymous
Not applicable

The entire CAN message is stored in those registers. The complete CAN ID, DLC and payload are all there.

   

 

   

Which bits do you feel are missing?

0 Likes
Reply
Anonymous
Not applicable

Ok, that's true. But I got confused when I searched for possible ways to access the seperate parts. For example, how do I access the RTR-bit? Or how could I access the whole range of data-bits and copy it with just one call to memcpy?

   

For single bits I already found defines or "functions" to access them, e.g. MyCANInstance_GET_DLC. But why is there no equivalent way to access RTR in the RX register? Do I have to access it directly via MyCANInstance_RX[mailboxID].rxcmd.byte[21u]?

0 Likes
Reply
Anonymous
Not applicable

It also demands for bit-fields when accessing things like DLC which is stored in more than one bit but less than 8 bit = 1 byte.

0 Likes
Reply
Anonymous
Not applicable

I just memcpy() or DMA the entire mailbox (CAN_RX_STRUCT) and work with that. It seemed easiest.

0 Likes
Reply
Anonymous
Not applicable

OK, but then you still need a bit field for accessing the single or grouped bits like DLC or RTR in e.g. rxcmd, right?

0 Likes
Reply
Anonymous
Not applicable

 well if you're copying the entire structure you can just reference the elements directly... Something like

   

 

   
 struct CAN_RX_STRUCT *c;   c = &CAN_RX[mbox];   ide = CAN_RX[mbox].rxcmd.byte[2] & (1 << 4);  dlc = CAN_RX[mbox].rxcmd.byte[2] & 0x0f;  id = *(uint32_t *)&CAN_RX[mbox].rxid.byte[0];  id >>= 3;
   

 You can find the positions of the desired information by looking at the register TRM for the PSoC5LP.

0 Likes
Reply
Anonymous
Not applicable

Ok, I see. Thanks for clarifying this!

0 Likes
Reply