hi i've been unable to loopback any can frames. i've tried all examples here on the forum without any luck. i enabled int service. breakpoint on CAN1_OnFreeTxBuffer DOES hit, but CAN1_OnFullRxBuffer does NOT.
here's some code snippets:
events.c:
void CAN1_OnFullRxBuffer(LDD_TUserData *UserDataPtr, LDD_CAN_TMBIndex BufferIdx)
{
canrx = TRUE;
/* Write your code here ... */
}
main.c:
extern bool canrx;
LDD_TDeviceData *MyCANPtr=NULL;
LDD_TError Error;
LDD_CAN_TFrame Frame,RFrame;
void can_test(void)
{
LDD_CAN_TAccMask AccMask;
uint8_t OutData[8] = {0x00U, 0x01U, 0x02U, 0x03U};
Frame.MessageID = 0x123U; /* Set Tx ID value - standard */ /* Set Tx ID value - standard */
Frame.FrameType = LDD_CAN_DATA_FRAME; /* Specyfying type of Tx frame - Data frame */
Frame.Length = sizeof(OutData); /* Set number of bytes in data frame - 4B */
Frame.Data = OutData; /* Set pointer to OutData buffer */
//DataFrameTxFlg = FALSE; /* Initialization of DataFrameTxFlg */
Error = CAN1_SendFrame(MyCANPtr, 1U, &Frame);
Error = CAN1_GetAcceptanceMask(MyCANPtr, 0U, &AccMask );
}
int main(void)
{
/* Write your local variable definition here */
MyCANPtr = CAN1_Init(NULL);
for(;;){
WAIT1_Waitms(5); | |||
if(canrx){ | |||
canrx=FALSE; |
RFrame.Data = InpData; | ||
Error = CAN1_ReadFrame(MyCANPtr, 0U, &RFrame); | ||
} |
cnt++; | ||||
if ((cnt%1024)==0) { /* from time to time, write some text */ |
can_test(); |
}}
thanks for any pointers
david
已解决! 转到解答。
Hi David,
So sorry for it , i will attach it this time if need .
And about this "i enabled global acceptance mask of 0x1ffffff.. doesn't that mean it should accept all msgs?" ,yes ,
it can accept all msgs.
While here you configure it receive the ID 0x7ff
while in your project you writ the send can ID is 12473156, not 0x7ff.
Frame.MessageID = (12473156 | LDD_CAN_MESSAGE_ID_EXT);
Hope it helps
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello David,
From your project , i have not find the send data project , so i create one
new project for the CAN-loopback about the chip of mk22fn1m0vlk12 , and as
to i have not this chip , so i test it on the similar chip , it can work well , can run into
the receive interrupt ,
please test it on your side .
BR
Alice
Alice,
i figured it out. i had to put a messageID in the rx buffer, and send a frame with that msg id.
Confusing though cause i enabled global acceptance mask of 0x1ffffff.. doesn't that mean it should accept all msgs?
Hi David,
So sorry for it , i will attach it this time if need .
And about this "i enabled global acceptance mask of 0x1ffffff.. doesn't that mean it should accept all msgs?" ,yes ,
it can accept all msgs.
While here you configure it receive the ID 0x7ff
while in your project you writ the send can ID is 12473156, not 0x7ff.
Frame.MessageID = (12473156 | LDD_CAN_MESSAGE_ID_EXT);
Hope it helps
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi david,
From the PE configuration , it seems there is no error.
Pleas test the demo code under KSDK1.3 on your board :
KSDK_1.3.0\examples\twrk21f120m\driver_examples\flexcan\flexcan_loopback\kds
Pay attention , when you download the project , please select the part number or your chip,
and also please send your project to me , i will test it on my side the TWR-K21 board ,
i have test the demo on my board , it can run into the receive interrupt , while i have not the
chip "mk22fn1m0vlk12 " , so only need your help to test the demo , then i would be confirm
whether is the project error or the chip .
BR
Alice
hi Alice,
yes i do use PE. and 'self reception' was set already. i've tried auto and non-auto initialization.
btw all methods called return 0x0 (ERR_OK)
here's all component inspector screens
Hello David,
From your code , it seems that you use the Processor Expert project ,
if yes, please also enalbe the "Self reception"on the CAN_LDD component :
If you do not use the PE, please set the SRXDIS to 0 to enable it on the CANx_MCR register .
Hope it helps
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------