This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hey,
maybe someone could help me here with my Issue, so i try to explain it below.
I initialized a master slave configuration between 2 microcontrollers. A TM4C123GH6PM as a slave and a TM4C1294NC as a master.
The slave has got 2 QEI modules, one of them detects a coding strip and sends this information via can to the master. If i do not slide the film through the sensor, it works fine and the slave, sends the actuell Position back.
If i slide the coding strip, it sends for a minimum of time the Position and suddenly messages got lost. The master checks if the slave answered the request for the 2 QEI modules and ends the transmission in this case.
There is a uncommeted line with the "for" statement, which i use, to create a delay. With that line it works but this is very unproperly. Maybe there is a statement to check if the message is completly sent.
Below, some code from the slave. The first message, is the information from the coding strip. This is the message which has got the sending problem, with the last message i sent, there is no problem.
I send you only this code because i think, there is the problem, if you need more information, don't hesitate to ask.
I would be very happy about help.
/* RX handler */ case 2: CANIntClear(CAN0_BASE, 2); // ui32CanRxFlags = (ui32CanRxFlags | 0b10); sMsgObjectDataRx0.pui8MsgData = pui8RxBuffer; CANMessageGet(CAN0_BASE, 2, &sMsgObjectDataRx0, 0); TestVariable = pui8RxBuffer[0]; if(TestVariable == 200) { Position = QEIPositionGet(QEI0_BASE); pui8TxBuffer[0] = Position; CANMessageSet(CAN0_BASE, 1, &MsgObjectTx, MSG_OBJ_TYPE_TX); //for (i = 0; i < 100000; i++); //Teil für Winkel Position = QEIPositionGet(QEI1_BASE); pui8TxBufferWinkel[0] = Position; CANMessageSet(CAN0_BASE, 3, &MsgObjectTx1, MSG_OBJ_TYPE_TX); } break;
I suspect that you are overwriting the the transmit mailbox before the previous message was sent. Try adding a call to CANStatusGet() and check if a transmission is still pending before the call to CANMessageSet() (line 11 in you code snippet above.)
// Wait for previous transmission to complete (mailbox 1) while((CANStatusGet(CAN0_BASE, CAN_STS_TXREQUEST) & 1) == 1);