- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to suggest a feature that would allow multiple configurations to be set up through the customizer. In an automotive CAN application, it is required to try 2 different baud rates and 11 bit and 29 bit ID format. It is difficult to work with the CAN_RX_CFG and CAN_TX_CFG structs to reinitialize the CAN mailboxes with different values for switching between the 11 and 29 bit ID formats.
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You dont have to change the CAN_RX_CFG and CAN_TX_CFG structs to change the baud rate or IDE . You can directly write to the CAN register to do the same
Changing Baud Rate
The Bridge allows to you operate in one of the following Baud rates 1000, 800, 500, 250, 125, 62.5, 20 and 10 Kbps. Though the CAN protocol does not have any limitation on the Baud rate, these are the standard values this project currently supports. The default Baud rate is 1000 Kbps.
To change the Baud rate you need to modify the PreScaler value and time segment values of the CAN component. Below is the simple code snippet showing the same.
if(CAN_SetPreScaler(BRP)==CYRET_SUCCESS)
CAN_SetTsegSample(tseg1,tseg2,sjw,sample_mode);
The following table gives you the values of the BRP, tseg1, tseg2, sjw and sample modes for the various Baud rates supported in this project.
Baud Rate (Kbps) | BRP | Tseg1 | Tseg2 | SJW | Sample mode |
1000 | 0x01 | 0x08 | 0x01 | 0x00 | 0x00 |
800 | 0x01 | 0x0B | 0x01 | 0x00 | 0x00 |
500 | 0x02 | 0x0C | 0x01 | 0x00 | 0x00 |
250 | 0x05 | 0x0C | 0x01 | 0x00 | 0x00 |
125 | 0x0B | 0x0C | 0x01 | 0x00 | 0x00 |
62.5 | 0x17 | 0x0C | 0x01 | 0x00 | 0x00 |
20 | 0x4A | 0x0C | 0x01 | 0x00 | 0x00 |
10 | 0x95 | 0x08 | 0x01 | 0x00 | 0x00 |
Regards,
Sobi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Peter,
You can also change the IDE through register write.
Changing the IDE and RTR Bit Field
To set or clear the IDE and RTR bit fields you need to modify the CAN TX CMD register. The CAN Component has 8 TX mailbox and each mailbox has on TX CMD register defined. This TX CMD register is 32 bit register in which bit 20 and 21 corresponds to the IDE and RTR respectively. By writing to TX CDM register you can set as well clear the IDE and RTR bits. The following #defines will allow you to do that
/* Set the IDE for a particular mailbox */
CAN_SET_TX_IDE(Mailbox_No);
/* Clear the IDE for a particular mailbox */
CAN_CLEAR_TX_IDE(Mailbox_No);
/* Set the RTR for a particular mailbox */
CAN_SET_TX_RTR(Mailbox_No);
/* Clear the RTR for a particular mailbox */
CAN_CLEAR_TX_RTR(Mailbox_No);
Regards,
Sobi