A CAN mailbox sharing and sending method

By introducing top-level mailbox sharing signals into the CAN communication system, mail information sharing and coordination between CANs are realized, and the problem of limited mail transmission between multiple CANs in the prior art is solved, thereby improving the efficiency and flexibility of the system.

CN118842671BActive Publication Date: 2025-02-25HUNAN ADVANCECHIP ELECTRONICS TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411090214.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2025-02-25
Estimated Expiration
2044-08-09

AI Technical Summary

Technical Problem

In the existing CAN bus communication system, the transmission of mail information between multiple CANs is limited by the transmission rate of 1Mbit/s, and the mailbox information is independent and cannot be effectively shared and coordinated.

Method used

A CAN mailbox sharing and sending method is proposed, and by introducing top-level mailbox sharing signals in the CAN communication system, mail information sharing and coordination between CANs are realized. The specific steps include sending read and write commands, waiting for the answer signal, locking the chip selection signal, performing read and write operations, and updating the mailbox fill status.

Benefits of technology

It effectively avoids the problem of mutual transmission of mail in the same chip system, improves the access efficiency and flexibility between mailboxes, expands the number of CAN mail storage, and reduces the resource usage of CAN bus.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118842671B_ABST
    Figure CN118842671B_ABST
Patent Text Reader

Abstract

A CAN mailbox sharing and sending method includes: S1, the i-th CAN_i sends a read-write command to the j-th CAN_j, and locks the read-write command of CAN_i, the read-write command is used to read and write the mailbox of the j-th CAN_j; S2, CAN_i waits for the response signal ACK_j of CAN_j; CAN_i receives the response signal ACK_j of CAN_j; S3, when the read-write command is a read operation, CAN_j sends the email information; when the read-write command is a write operation, CAN_i sends the email information to CAN_j; S4, CAN_j completes the CAN_i read-write operation, responds to ACK_j, and pulls ACK_j low. The present invention adds a peripheral signal of CAN, realizes the email information transmission method between mailboxes in the same chip system, greatly improves the access efficiency between mailboxes, and reduces the resource occupation of the CAN bus.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a CAN mailbox shared sending method. Background Art

[0002] The CAN (Multi-Host Local Area Network Serial Communication Protocol) communication protocol is mainly used for in-vehicle communication. Multiple CANs are mounted on the CAN bus to form a multi-host local area network, which allows fast, safe and efficient communication between CAN mailboxes and quickly adapts to today's increasingly intelligent in-vehicle systems.

[0003] The CAN bus signal is transmitted through the bus interface on two differential voltage signal lines. The CAN email information is transmitted to another CAN mailbox through the serial port to complete the information transmission. If the email information transmission between multiple CANs in the same chip system is transmitted through the differential voltage signal line, it will be limited by the CAN transmission rate of 1Mbit / s. In addition, the existing CAN mailbox information is independent.

[0004] The background description provided herein is for the purpose of generally presenting the context of the present disclosure. Unless otherwise indicated herein, the materials described in this section are not prior art to the claims of this application and are not admitted to be prior art by inclusion in this section. Summary of the invention

[0005] In view of the above technical problems in the related art, the present invention proposes a CAN mailbox sharing sending method, which is applied to a CAN communication system, wherein the system includes N CANs, the N CANs communicate through a CAN bus, the N CANs have a CAN top-level mailbox sharing signal, the CAN internal mailbox includes sending mails and receiving mails, and N is a positive integer greater than 1; the method comprises the following steps:

[0006] S1, the i-th CAN_i sends a read / write command to the j-th CAN_j, and locks the read / write command of CAN_i, wherein the read / write command is used to read / write the mailbox of the j-th CAN_j; i and j are both positive integers less than or equal to N;

[0007] S2, CAN_i waits for the response signal ACK_j from CAN_j; CAN_i receives the response signal ACK_j from CAN_j;

[0008] S3, when the read / write command is a read operation, CAN_j sends the email information; when the read / write command is a write operation, CAN_i sends the email information to CAN_j;

[0009] S4, CAN_j completes the CAN_i read and write operations, responds to ACK_j, and pulls ACK_j low, and CAN_j continues to poll the CS signal.

[0010] Specifically, the step S1 further includes: sending a chip select signal CS_i[j] for selecting to read and write CAN_j; CS_i[j] represents a chip select signal sent by CAN_i to CAN_j;

[0011] CAN_i sends the read and write command WR_i[j][n] for email n; WR_i[j][n] indicates the read and write command for email n sent by CAN_i to the mailbox CAN_j.

[0012] Specifically, sending a chip select signal CS_i[j] for selecting to read and write CAN_j is to configure CS_i[j] through a DSP or other host.

[0013] Specifically, the step S2 further includes:

[0014] CAN_i does not wait for the response signal ACK_j from CAN_j; then the chip select CS_i[j] is manually canceled; the manual cancellation is to write zero operation to the chip select CS register of CAN_j accessed by the DSP or other host to the CAN_i;

[0015] If CAN_i does not wait for the response signal ACK_j from CAN_j and does not manually cancel the chip select CS_i[j], it continues to wait, and the read and write commands of CAN_i continue to be locked.

[0016] Specifically, if the user does not wait for ACK_j for a long time, the user can clear the register CS_i[j] bit through the DSP or other host to release the request, or update the mailbox request CS_i[n] to access other CAN_n.

[0017] Specifically, when the CAN_j mailbox is in a busy state, the system continues to wait, and when the CAN_j mailbox is idle, the system sends a response signal ACK_j.

[0018] Specifically, the step S4 further includes: when the read / write command is a read operation, updating the filling status of the CAN_i mailbox; when the read / write command is a write operation, updating the filling status of the CAN_j mailbox.

[0019] Specifically, after step S4, the method further includes:

[0020] S5, when receiving the response ACK_j as a low signal, unlock the read and write commands of CS_i[j] and CAN_i.

[0021] Specifically, the unlocking of CS_i[j] is to clear the register CS_i[j] bit through the DSP or other host.

[0022] In a second aspect, another embodiment of the present invention discloses a CAN mailbox sharing processing method, which is applied to a CAN communication system, wherein the system includes N CANs, the N CANs communicate through a CAN bus, the N CANs have a top-level mailbox sharing signal of the CAN, the CAN internal mailbox includes sending mails and receiving mails, and N is a positive integer greater than 1;

[0023] S1, when CAN_j is in idle state, polling detection receives the chip select CS_n[j] command. When CAN_j detects the CS_i[j] command, CAN_j sends the response signal ACK_j[i];

[0024] S2, after the response, for a read operation, CAN_j sends email n to CAN_i; for a write operation, CAN_j receives email n from CAN_i;

[0025] S3, CAN_j is in idle state, and polls to check the sending chip select CS request and receiving CS request command.

[0026] In a third aspect, another embodiment of the present invention discloses a CAN mailbox shared sending method, which is applied to a CAN communication system, wherein the system includes N CANs, the N CANs communicate through a CAN bus, the N CANs have a top-level mailbox sharing signal of the CAN, the CAN internal mailbox includes sending mails and receiving mails, and N is a positive integer greater than 1;

[0027] S1, DSP or other host configures CAN_i read and write command chip select CS

[0028] S2, polling detects that CAN_i sends a request command CS_i[j] to read and write mail n;

[0029] S3, wait for response, if there is no response, clear CS_i[j] through DSP or other host and continue polling detection;

[0030] If CAN_j responds, the CAN read and write mailbox commands are locked, no new request commands are sent, and the CAN_i mail n is not accessed by the bus network inside the chip;

[0031] After the response, for the read operation of CAN_i, CAN_i waits to receive the mail n from CAN_j;

[0032] After the response, for the write operation of CAN_i, CAN_i sends the information of email n to CAN_j;

[0033] S4: After the response is completed, release the lock and continue to poll the CS signal.

[0034] When sending a read-write command, the present invention firstly selects the top-level mailbox sharing signal of the corresponding CAN, waits for the corresponding CAN response signal, and locks the chip selection signal of the corresponding CAN according to the response signal, and then the corresponding CAN operates according to the corresponding read-write instruction, and updates the filling status of the corresponding CAN mailbox. This method can effectively avoid the problem of mutual transmission of mails in the same chip system, and coordinate resources through the characteristics of mutual mailbox sharing, greatly increasing the efficiency and flexibility of the use of CAN mailboxes, and correspondingly expanding the number of CAN mail storage. That is, the present invention adds a peripheral signal of CAN, and on the basis of the original internal system network communication, realizes the mail information transmission method between mailboxes in the same chip system, greatly improving the access efficiency between mailboxes and reducing the resource occupation of the CAN bus. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0036] Figure 1 It is a structural diagram of a CAN mailbox sharing provided by an embodiment of the present invention;

[0037] Figure 2 This is a schematic diagram of a command sent by a CAN mailbox sharing provided by an embodiment of the present invention;

[0038] Figure 3 This is a schematic diagram of a command sent by a CAN shared mailbox in coordination according to an embodiment of the present invention;

[0039] Figure 4 This is a CAN mailbox sharing sending method process provided by an embodiment of the present invention Figure 1 ;

[0040] Figure 5 This is a CAN mailbox sharing sending method process provided by an embodiment of the present invention Figure 2 ;

[0041] Figure 6 It is a CAN flow chart of CAN_i sending a read / write command request provided by an embodiment of the present invention;

[0042] Figure 7 It is an internal flow chart of CAN_j for the command of CAN_j receiving mail n provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0043] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field belong to the scope of protection of the present invention.

[0044] Embodiment 1

[0045] refer to Figure 1 A CAN mailbox sharing method of this embodiment is used in a CAN communication system, wherein the CAN communication system includes N CAN communication interfaces CAN_0...CAN_N, each of which has one or more mailboxes, that is, each communication interface can read and write a corresponding mailbox. In the prior art, the internal mailbox of the CAN is generally accessed through the chip internal system bus network (wherein the chip internal system bus network is used to configure the registers and mailbox contents of the CAN), such as the AMBA bus, and the email information of the CAN mailbox is triggered to be transmitted to the CAN bus interface (wherein the CAN bus interface is used for CAN to send / receive emails), so as to transmit email information between CANs. As a result, in the same chip system, the transmission of email information between multiple CANs is limited to the 1Mbit / s transmission rate of CAN through the differential voltage signal line.

[0046] refer to Figure 2-3 This embodiment discloses a CAN mailbox sharing method, where each CAN mailbox can receive mailbox sharing status and control, and then control the mailbox according to the mailbox sharing status and control information. The mailbox sharing status and control information of this embodiment is expressed through the response and control information of the corresponding command, such as the ACK response to the read and write command, the CAN response of the coordinated send command and its control information. The specific implementation method refers to the following specific description.

[0047] By mutually transmitting the status and control information of mailbox sharing between each CAN, the delivery and receiving of mails between each CAN can be completed by applying for other mailboxes to coordinate sending requests, reading other mailboxes' mail information requests, obtaining other mailboxes' working status, sending and receiving mails to other mailboxes, other mailboxes or returning the empty and full status information of their own mailboxes, etc. The shared information of the mailbox can be shared. The working status of the mailbox in this embodiment includes: mailbox lock command, mailbox reply command ACK, etc.; the empty and full status information of the mailbox is confirmed by the mailbox filling status. The CAN interface of this embodiment will send and receive commands, and in the process of executing and completing the command, the status information is all inside each CAN, and is output according to the operating status of each CAN, and each CAN receives the internal status information (such as mailbox filling, mail information, etc.) from each CAN, but confirms the status information of the CAN that needs to be received through the command, and performs the corresponding status response.

[0048] This embodiment takes CAN_0 coordinating other CAN shared mailboxes in the same chip system as an example. The specific CAN external communication architecture diagram is as follows: Figure 1 As shown. For each CAN newly added peripheral signal, the newly added peripheral signals include: the control signal wr_n[n:0] for reading and writing mailboxes, the chip select signal cs_n[n:0] of CAN, the mailbox response signal ack_n[n:0], the mail [n] send request, the CAN [n] response to the mail send request, and the filling status of the mailbox, and judge the types of other CAN requests: mailbox read and write request, coordination mail send request, CAN response to the mail generation request, and the filling status of the mailboxes between each other. Through these basic information, the information sharing of shared mails and resource coordination are completed.

[0049] The CAN shared mailbox of the present invention has two operation modes: mail reading and writing operation, and mail coordinated sending operation.

[0050] The first type: mail read and write operations: mail read and write request wr_0[1] mail n is the reading and writing of the nth mail in the mailbox of CAN_1 by CAN_0. The read operation will not modify the filling status of the mailbox, and the write operation will update the filling status of the mailbox. By judging each CAN's response to CAN_0's request, it is confirmed which CAN receives the read and write request command.

[0051] The second type: coordinated sending of mail: The sending request of mail n[0] is the sending request of the nth mailbox initiated by CAN_0, in which CAN_0 confirms which CAN receives the sending request command by polling. Once confirmed, the coordinated sending function of the sending request CAN_0 is locked by the receiving command CAN. Only when the receiving command CAN is sent or released manually, can CAN_0 start the coordinated sending function. The filling status of the mailbox of the CAN receiving the command will not be updated. After the sending is completed, the filling status of the CAN_0 mailbox itself needs to be manually updated. The manual update of this embodiment refers to the read and write operations of the filling status register of the mailbox through the DSP or other host.

[0052] The shared mailbox coordinates sending. After the sending is completed, the filling status of the mailbox will not change, and the lock status of the mailbox will be released. At this time, the user can send again as needed. If there is no need to send again, the DSP or other host will clear the filling status bit of the mailbox to prevent secondary sending and save CAN bus resources. That is, this embodiment controls the filling status bit of the mailbox by whether the user sends again (manual update) as needed. The significance of manual is that it increases the flexibility of user use and adds the possibility that the user needs to send again.

[0053] refer to Figure 4-5 , this embodiment discloses a CAN mailbox sharing sending method, which is applied to a CAN communication system, wherein the system includes N CANs, the N CANs communicate through a CAN bus, the N CANs have a CAN top-level mailbox sharing signal, the CAN internal mailbox includes sending mails and receiving mails, and N is a positive integer greater than 1;

[0054] It includes the following steps:

[0055] S1, the i-th CAN_i sends a read-write command to the j-th CAN_j, and locks the read-write command of CAN_i, wherein the read-write command is used to read and write the mailbox of the j-th CAN_j;

[0056] The specific step S1 also includes: sending a chip select signal CS_i[j] for selecting to read and write CAN_j; indicating that CS_i[j] is a chip select signal sent by CAN_i to CAN_j;

[0057] CAN_i sends the read and write command WR_i[j][n] of email n; WR_i[j][n] represents the read and write command of email n sent by CAN_i to the mailbox of CAN_j;

[0058] The locked read and write commands cannot be updated unless they are manually canceled or CS_i[j] is updated;

[0059] In step S1 of this embodiment, the jth CAN_j is first selected by polling, and then CAN_i sends the read and write command WR_i[j][n] of the mail n. Specifically, CAN_i sends the chip select CS command, which is to modify the CS information through DSP or other hosts. CS_i can be a plurality of bit mailboxes. For example, there are 3 CANs inside the chip, and each CAN mail has 16 bits. CS_2[0] and CS_0[1] are modified by DSP or other hosts to be set to 1. The polling method is from CS_2[0] to CS_2[1], and checks are made in sequence. When CS_2[0]=1 is checked, a command is sent to CAN_0. After the command is completed, the request of CS_1[0] is executed. If the waiting time is too long, the request can be abandoned and the request of the corresponding bit of CS can be manually cleared.

[0060] S2, CAN_i waits for the response signal ACK_j from CAN_j; when CAN_i receives the response signal ACK_j from CAN_j;

[0061] When CAN_i receives the response signal ACK_j from CAN_j, CS_i[j] of CAN_i is locked; the response signal ACK_j in this embodiment is high, and the high value of ACK_j may be 1.

[0062] When the read / write command is a read operation, CAN_i waits for the email n of CAN_j to be sent;

[0063] When the read / write command is a write operation, CAN_i sends the information of mail n to CAN_j;

[0064] Step S2 also includes:

[0065] If CAN_i does not wait for the response signal ACK_j from CAN_j, the chip select CS_i[j] is manually canceled.

[0066] For the read and write operations on the CAN_j mailbox, the DSP or other host accesses the register CS[j] bit. CAN_i generates a read and write command for CAN_j. If CAN_j does not reply ACK for a long time, the CS_i[j] of CAN_i is locked. The CS_i[j] bit of the CAN_i register can be cleared by the DSP or other host.

[0067] If the user does not wait for ACK_j for a long time, the user can clear the register CS_i[j] bit through the DSP or other host to release the request, or update the mailbox request CS_i[n] to access other CAN_n, thereby improving the exchange efficiency of the mailbox shared with other CAN_n.

[0068] The read and write commands of the shared mailbox CAN_i are implemented by polling CS_i[n]. If there is no response within a certain period of time, the DSP or other host is configured to clear the register CS_i[j] bit. After the polling is completed, the CS_i[j] bit or other unresponded CS bits are configured again to ensure the read and write efficiency of CAN_i.

[0069] There are several possibilities that CS_i[j] in this embodiment is not answered:

[0070] The mail position corresponding to WR_i[j][n] may mean that the bus is reading or writing mail n, and mail n is busy.

[0071] Read the mail n position corresponding to WR_i[j][n], CAN_j mail n is not filled

[0072] Write WR_i[][n] corresponding to the mail n position, CAN_j mail n has been filled and is in a valid state;

[0073] Manual cancellation: It is to write zero operation to the chip select CS register of other CANs through DSP or other hosts;

[0074] If no response is received and the request is not cancelled, the waiting process continues and the read and write commands of CAN_i continue to be locked.

[0075] S3, when the read / write command is a read operation, CAN_j sends the email information; when the read / write command is a write operation, CAN_i sends the email information to CAN_j;

[0076] S4, CAN_j completes the read and write operations of CAN_i, responds to ACK_j, and pulls ACK_j low, and CAN_j continues to poll the CS signal;

[0077] In this embodiment, ACK_j is pulled low, and ACK_j may be 0.

[0078] When the read / write command is a read operation, updating the filling status of the CAN_i mailbox;

[0079] When the read / write command is a write operation, updating the filling status of the CAN_j mailbox;

[0080] Furthermore, after step S4, the method further includes: when receiving a response ACK_j which is a low signal, unlocking the read and write commands of CS_i[j] and CAN_i.

[0081] When sending a read / write command, this embodiment first selects the top-level mailbox sharing signal of the corresponding CAN, waits for the corresponding CAN's response signal, and locks the corresponding CAN's chip selection signal according to the response signal. Then the corresponding CAN operates according to the corresponding read / write instruction and updates the filling status of the corresponding CAN mailbox. This method can effectively avoid the problem of mutual transmission of emails in the same chip system, and coordinate resources through the mutual mailbox sharing characteristics, greatly increasing the efficiency and flexibility of the use of CAN mailboxes, and correspondingly expanding the number of CAN email storage. That is, this embodiment adds a peripheral signal of CAN, and on the basis of the original internal system network communication, realizes the email information transmission method between mailboxes in the same chip system, greatly improving the access efficiency between mailboxes and reducing the resource occupation of the CAN bus.

[0082] Embodiment 2

[0083] refer to Figure 6 , this embodiment discloses a CAN mailbox sharing sending method, which is applied to a CAN communication system, wherein the system includes N CANs, the N CANs communicate through a CAN bus, the N CANs have a CAN top-level mailbox sharing signal, the CAN internal mailbox includes sending mails and receiving mails, and N is a positive integer greater than 1;

[0084] In one embodiment, the number of sent emails is 3 and the number of received emails is 2.

[0085] The method of this embodiment is described by taking the process of CAN_i sending commands and processing emails.

[0086] The steps are as follows:

[0087] S1, DSP or other host configures CAN_i read and write command chip select CS

[0088] S2, polling detects that CAN_i sends a request command CS_i[j] to read and write mail n;

[0089] S3, wait for response, if there is no response, clear CS_i[j] through DSP or other host and continue polling detection;

[0090] If CAN_j responds, the CAN read and write mailbox commands are locked, no new request commands are sent, and the CAN_i mail n is not accessed by the bus network inside the chip;

[0091] After the response, for the read operation of CAN_i, CAN_i waits to receive the mail n from CAN_j;

[0092] After the response, for the write operation of CAN_i, CAN_i sends mail n to CAN_j.

[0093] After the response, CAN_i mail n is defaulted to the filled state. If CAN_i sends the specified mail n, it needs to wait until the lock is released before sending;

[0094] After the response, CAN_i mail n is locked, and the chip internal system bus (AMBA bus) accesses mail n. Only after waiting to be unlocked can the chip system bus access mail n. If access to mail n is not specified, access to mail n+1 is skipped. If access to mail n is specified, it is necessary to wait for unlocking.

[0095] After the response, the read operation, CAN_i mail n is filled by default, and mail n is locked. The locking means that CAN mail n is not modified by the internal bus of the system, nor is mail n sent by the CAN bus interface. Only after the lock is unlocked (receive the response and pull it low), if the CAN bus interface sends a mail n command, mail n will be sent out. Before the lock is unlocked, the CAN bus interface is in a waiting state; and once mail n is locked, mail n is filled by default to prevent the internal bus of the chip system from modifying CAN.

[0096] After the response, write operation, CAN message n is written to CAN_j. After the write operation is completed, CAN needs to manually update the filling status of message n.

[0097] S4: After the response is completed, release the lock and continue to poll the CS signal.

[0098] After the response of this embodiment is completed, the ACK signal is pulled low.

[0099] When sending a read-write command, the present invention firstly selects the top-level mailbox sharing signal of the corresponding CAN, waits for the corresponding CAN response signal, and locks the chip selection signal of the corresponding CAN according to the response signal, and then the corresponding CAN operates according to the corresponding read-write instruction, and updates the filling status of the corresponding CAN mailbox. This method can effectively avoid the problem of mutual transmission of mails in the same chip system, and coordinate resources through the characteristics of mutual mailbox sharing, greatly increasing the efficiency and flexibility of the use of CAN mailboxes, and correspondingly expanding the number of CAN mail storage. That is, the present invention adds a peripheral signal of CAN, and on the basis of the original internal system network communication, realizes the mail information transmission method between mailboxes in the same chip system, greatly improving the access efficiency between mailboxes and reducing the resource occupation of the CAN bus.

[0100] Embodiment 3

[0101] refer to Figure 7, this embodiment discloses a CAN mailbox sharing processing method, which is applied to a CAN communication system, wherein the system includes N CANs, the N CANs communicate through a CAN bus, the N CANs have a CAN top-level mailbox sharing signal, the CAN internal mailbox includes sending mails and receiving mails, and N is a positive integer greater than 1;

[0102] CAN_j receives the command of mail n, the processing flow of CAN_j,

[0103] S1, when CAN_j is in idle state, polling detection receives the chip select CS_n[j] command. When CAN_j detects the CS_i[j] command, CAN_j sends the response signal ACK_j[i];

[0104] CAN_j receives read and write mail n commands. When CAN_j is in idle state, it will receive read and write mail n commands. Specifically, CAN_j does not send request command CS_j to other CANs, CAN_j's system bus does not access mail n, CAN_j does not send mail n to the CAN bus interface, or other operations are performed on reading and writing mail n.

[0105] When CAN_j is in idle state, polling detection receives the chip select CS_n[j] command. When CAN_j detects the CS_i[j] command, the read / write command received by CAN_j is a write operation, CAN_j mail n is not empty, and CAN_j does not respond to the request of CS_i[j]. The read / write command is a read operation, CAN_j mail n is empty, and CAN_j does not respond to the request of CS_i[j].

[0106] CAN_j receives the read and write command as a write operation. Under the condition that CAN_j mailbox n is empty, CAN_j sends a response signal ACK_j[i] to CAN_i. The filling status of mailbox n can also be cleared by DSP or other hosts, and CAN_j sends a response signal ACK_j[i]. After the response, CAN_j's mail n is locked and is not sent to the CAN bus interface by CAN_j, and the system internal bus cannot modify the mail information.

[0107] CAN_j receives read and write commands as read operations. Under the condition that CAN_j mailbox n is not empty, that is, in the filled state, CAN_j will send a response signal. After the response, CAN_j's mail n is locked and will not be sent to the CAN bus interface by CAN_j, and the system internal bus cannot modify the mail information.

[0108] S2, after the response, for a read operation, CAN_j sends email n to CAN_i; for a write operation, CAN_j receives email n from CAN_i;

[0109] After the response, CAN_j's mail n is defaulted to the filling state. If CAN_j specifies to send mail n, the sending state of CAN_j is always in the waiting state. Only after CAN_j's response fails, CAN_j's mail n is sent to the CAN bus interface by CAN_j. If the chip system bus specifies to access CAN_j's mail n, mail n is accessed by the chip system bus only after CAN_j's response fails (pulled low).

[0110] After the response, for the read operation, CAN_j mail n is sent, and the filling status of mail n needs to be manually modified through DSP or other host, and a response signal is sent; for the write operation, CAN_i receives mail n, automatically updates the filling status of mail n, and sends a response signal.

[0111] S3, CAN_j is in idle state, and polls to check the sending chip select CS request and receiving CS request command.

[0112] In the present invention, CAN_j receives the chip selection CS_n[j] command through polling detection in an idle state. When CAN_j detects the CS_i[j] command, CAN_j sends a response signal ACK_j[i], and then the corresponding CAN operates according to the corresponding read and write instructions, and updates the filling status of the corresponding CAN mailbox. This method can effectively avoid the problem of mutual transmission of emails in the same chip system, and coordinate resources through the characteristics of mutual mailbox sharing, greatly increasing the efficiency and flexibility of the use of CAN mailboxes, and correspondingly expanding the number of CAN email storage. That is, the present invention adds a peripheral signal of CAN, and on the basis of the original internal system network communication, realizes the email information transmission method between mailboxes in the same chip system, greatly improving the access efficiency between mailboxes and reducing the resource occupation of the CAN bus.

[0113] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A CAN mailbox sharing and sending method, applied to a CAN communication system, characterized in that: The system includes N CANs, the N CANs communicate via a CAN bus, the N CANs have a top-level mailbox sharing signal of the CAN, the CAN internal mailbox includes sending mails and receiving mails, and N is a positive integer greater than 1; the method includes the following steps: S1, the i-th CAN_i sends a read / write command to the j-th CAN_j, and locks the read / write command of CAN_i, wherein the read / write command is used to read / write the mailbox of the j-th CAN_j; i and j are both positive integers less than or equal to N; S2, CAN_i waits for the response signal ACK_j from CAN_j; CAN_i receives the response signal ACK_j from CAN_j; S3, when the read / write command is a read operation, CAN_j sends the email information; when the read / write command is a write operation, CAN_i sends the email information to CAN_j; When the read / write command is a read operation, the filling state of the CAN_i mailbox is updated; when the read / write command is a write operation, the filling state of the CAN_j mailbox is updated; S4, CAN_j completes the read and write operations of CAN_i, responds to ACK_j, and pulls ACK_j low, and CAN_j continues to poll the CS signal.

2. The method according to claim 1, characterized in that: The step S1 further includes: sending a chip select signal CS_i[j] for selecting to read and write CAN_j; CS_i[j] represents a chip select signal sent by CAN_i to CAN_j; CAN_i sends the read and write command WR_i[j][n] for email n; WR_i[j][n] represents the read and write command of email n sent by CAN_i to the mailbox of CAN_j.

3. The method according to claim 2, characterized in that: The step S2 further comprises: If CAN_i does not wait for the response signal ACK_j from CAN_j, the chip select CS_i[j] is manually canceled, and the manual cancellation is a write-zero operation of the chip select CS register of CAN_j accessed by the DSP or other host to the CAN_i; If CAN_i does not receive the response signal ACK_j from CAN_j and does not manually cancel the chip select CS_i[j], it continues to wait, and the read and write commands of CAN_i continue to be locked.

4. The method according to claim 3, characterized in that: If the user does not wait for ACK_j for a long time, the user can clear the register CS_i[j] bit through the DSP or other host to release the request, or update the mailbox request CS_i[n] to access other CAN_n.

5. The method according to claim 4, characterized in that: When the CAN_j mailbox is in a busy state, the system continues to wait, and when the CAN_j mailbox is idle, a response signal ACK_j is sent.

6. The method according to claim 1, characterized in that: After step S4, the method further includes: S5, when receiving the response ACK_j as a low signal, unlock the read and write commands of CS_i[j] and CAN_i.

7. The method according to claim 6, characterized in that: The unlocking of CS_i[j] is to clear the register CS_i[j] bit through the DSP or other host.

8. A CAN mailbox sharing processing method, applied to a CAN communication system, characterized in that: The system includes N CANs, the N CANs communicate via a CAN bus, the N CANs have a top-level mailbox sharing signal of the CAN, the CAN internal mailbox includes sending mails and receiving mails, and N is a positive integer greater than 1; the method includes the following steps: S1, when CAN_j is in idle state, polling detection receives the chip select CS_n[j] command. When CAN_j detects the CS_i[j] command, CAN_j sends the response signal ACK_j[i]; S2, after the response, for a read operation, CAN_j sends email n to CAN_i; for a write operation, CAN_j receives email n from CAN_i; After the response, for the read operation, CAN_j mail n is sent, and the filling status of mail n needs to be manually modified through DSP or other host, and a response signal is sent; for the write operation, CAN_i receives mail n, automatically updates the filling status of mail n, and sends a response signal; S3, CAN_j is in idle state, and polls to check the sending chip select CS request and receiving CS request command.

9. A CAN mailbox shared sending method, applied to a CAN communication system, characterized in that: The system includes N CANs, the N CANs communicate via a CAN bus, the N CANs have a top-level mailbox sharing signal of the CAN, the CAN internal mailbox includes sending mails and receiving mails, and N is a positive integer greater than 1; the method includes the following steps: S1, DSP or other host configures CAN_i read and write command chip select CS; S2, polling detects that CAN_i sends a request command CS_i[j] to read and write mail n; S3, wait for response, if there is no response, clear CS_i[j] through DSP or other host and continue polling detection; If CAN_j responds, the CAN read and write mailbox commands are locked, no new request commands are sent, and the CAN_i mail n is not accessed by the bus network inside the chip; After the response, for the read operation of CAN_i, CAN_i waits to receive the mail n from CAN_j; After the response, for the write operation of CAN_i, CAN_i sends email n to CAN_j; After the response, read operation, CAN_i mail n is filled in the default state, and mail n is locked; After the response, the write operation, mail n is written to CAN_j. After the write operation is completed, CAN needs to manually update the filling status of mail n; S4: After the response is completed, release the lock and continue to poll the CS signal.

Citation Information

Patent Citations

  • Design method for communication between CAN communication channels based on DSP2812

    CN106230688A

  • CAN bus controller data storage circuit and data storage method

    CN109981431A