TMS320F28335-CAN module routine explanation
[Copy link]
CAN (Controller Area Network) features: All units can send messages at the same time, and the unit that sends the high priority ID message. The biggest advantage of the CAN bus is its efficiency and reliability. In theory, there is no limit to the total number of units that can be mounted on the bus. In practice, the number of units that can be connected is limited by the time delay and electrical load on the bus.
The DSP has a built-in CAN protocol kernel CPK, which has 32 mailboxes that can be configured to receive or send. In eCAN mode, mailbox 31 has the highest priority.
Briefly explain the routines provided by TI:
1. The function of ECanaShadow: ECanaRegs does not support bit operations. In TI's routine, ECanaRegs is assigned to ECanaShadow to perform bit operations on the shadow register to improve the readability of the code.
2. After ECanaRegs.CANTRS is set, data starts to be sent. After successful transmission, the corresponding ECanaRegs.CANTAn will be set. Write 1 to it to reset it and continue sending.
3. In TI's ECANA_to_B routine, only the sending mailbox is configured. To implement CANA sending and CANB receiving, a receiving mailbox needs to be configured. The ID is the same as the sending mailbox. Pay attention to selecting the corresponding CAN pin on your board in ECan.c.
4.ECan receives information from the CAN_USB transmitter and determines whether the message is received by the value of ECanasShadow.CANRMP.bit.RMPn. When RMPn is 1, the message is received, and it continues to receive after writing 1 to reset it.
5. ECan receive interrupt configuration: ECanaShadow.CANGIM.bit.I0EN = 1, ECanaShadow.CANMIM.bit.MIMn = 1. Write 1 to RMPn in the interrupt function to reset and clear the interrupt flag of PIEACK.
Summary: ECANA and ECANB have been configured in ECan.c officially provided by TI. We only need to perform software reset on the corresponding RMPn (receive) and TAn (transmit) when receiving and sending to continuously receive and send.
PS: When debugging with the CAN_USB converter, pay attention to correct wiring and the baud rate of the converter must be consistent with the program configuration.
|