- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would just like to say how impressed I am with the PSoC and all the support documents provided by Cypress. I have been able to learn almost everything I need through the Cypress documentation or the forums, however, I have reached a roadblock. I have enabled CAN TX interrups, however, I am not sure how to see which TX message buffer caused the interrup. I think I need to access the CAN[0..0]_CSR_BUF_SR register, but I am just not sure how to read individual bits from the register.
Thanks,
Tom
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To simplify my question, how do you access a given byte of a register?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Reading a register and testing for a bit set is usually done by performing a bit-wise AND.
In C-language (as you certainly know) is done with the "&" operator. There are several bit-masks already defined for CAN-registers making the code more readable and as such life easier.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply. I have experience bitmasking, however, I do not know how to get the regester in the first place. In the examples, the ISR uses this line to clear the interrupt.
CAN_INT_SR_REG.byte[1u] = CAN_TX_MESSAGE_MASK;
However, it does not specifiy which TX buffer caused the interrupt.
It would help to be able to view the status of this register in the debugger, however, I have yet to find a way to view registers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"Register" is in the case of CAN only a name within a structure. You may see the structure's address and contents in the debugger. You have to investigate through the generated code. Easier could be to store the value into a local var and observe it in debugger;
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob,
Thanks for the suggestions. I had to be sure to set build options to debug mode so unused variables could be viewed in the debugger for easier debugging. Otherwise, the compiler would remove them.
Also, I found a solution to my problem. Instead of trying to directly access the register, I used a snippet of code from the generated CAN_TX_RX_func file that servers a similar purpose.
For the PSoC5LP:
(CAN_TX[1u].txcmd.byte[0u] & CAN_TX_REQUEST_PENDING)
This line of code checks the status of TX message buffer 1. It returns zero if the message has already been sent, and one if the message is waiting to be sent.