How to use RXMSCAN with processor expert with kea 128?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use RXMSCAN with processor expert with kea 128?

1,453 Views
emilioaronmoyer
Contributor III

Hello,

I'm trying to read an id of a bus CAN, I want to do that using RX interrupt, I'm using KEA128 and processor expert (CAN_LDD component).

Now I'm able to write to the bus CAN without interrupt, but when I try to read a message with a defined id nothing happens.

What I'm doing to read is the following:

 

FrameR.MessageID = 0x7DFU;                                       /* Set Tx ID value - standard */

  FrameR.FrameType = LDD_CAN_DATA_FRAME;                           /* Specyfying type of Tx frame - Data frame */

  FrameR.Length = sizeof(OutData2);

  FrameR.Data = OutData2; /* Set number of bytes in data frame - 4B */

  CAN1_ReadFrame(MyCANPtr,0,&FrameR);                   /* Sends the data frame over buffer 1 */

 

Does anyone know what i'm doing wrong and also what do I need to do to read using the Rx Can interrupt?

I attached the complete code for more details.

 

Regards,

Emilio

Original Attachment has been moved to: CAN_PE.rar

Labels (1)
0 Kudos
9 Replies

963 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Emilio,

There is a bug in the generated code in CAN1.c file ,it have not enable the interrupt.

Please add " MSCAN_PDD_EnableTxMessageBufferInterruptMask(MSCAN_BASE_PTR,0X01U);"

in the function of  LDD_TDeviceData* CAN1_Init(LDD_TUserData *UserDataPtr)

pastedImage_0.png

Hope it helps


Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

963 Views
emilioaronmoyer
Contributor III

Hello Alice,

I'm writting to the CAN bus every 100 ms using a timer interrupt without the TxInterrupt line you say, if i write de line the program doesn't work.

Do you know why??

And without the line is also working well the CAN1_OnFreeTxBuffer event in Events.c.

I'm having problems reading a message from CAN I don't know how is the syntax to receive a message, where can I indicate which ID is going to read? and from which variable can I retrieve the data read?

Regards,

Emilio

0 Kudos

963 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Emilio,

About the read data , you can refer to the demo code :

pastedImage_0.png

- About the receive ID, you can configure here to control mask which one :

pastedImage_1.png

you can combined with the related registers to understand:

MSCAN_CANIDAR

MSCAN_CANIDMR

MSCAN_RSIDR

About use which variable to receive data , as for the below, it will use the "Inpdata[]",

so it mainly rely on the Frame.Data .

pastedImage_2.png

Hope it helps


Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

963 Views
emilioaronmoyer
Contributor III

Hello Alice,

I refered to the demo code and the code needs the method.

pastedImage_0.png

But I didn`t find the method in the CAN_LDD component

pastedImage_1.png

What do I need to do to generate the method?

Another question, what do I need to write to the MSCAN_CANIDAR, MSCAN_CANIDMR, MSCAN_RSIDR if I want to read the ID0x7E8?

The reference manual there are a los of registers with those names

pastedImage_5.png

pastedImage_6.png

Regards,

Emilio Moyers

0 Kudos

963 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Emililo,

- This demo is for CAN  on KIneites K series , sorry for my mistake.

The method of SetRxBufferID is also for K series, so you can not find it.

About the CAN demo for kea-128 , please refer to this thread, there also have a demo and the introduce:

I wonder how to get CAN to work with KDS's Processor Expert?

-About receive ID , at default  it can receive all of the ID if you do not configure these register.

For the MSCAN module of KEA series , the ID related registers' function is mask which ID ,

so if you do not need mask Receive ID, you can do not care it .

Hope it helps


Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

963 Views
emilioaronmoyer
Contributor III

Hello Alice,

I can read one Id using the program in the help part of the CAN_LDD component. If I write this code in the program  main.c:

while(1){

  while (!DataFrameRxFlg) {}                                      /* Wait until data frame is received */

  FrameR.Data = InpData;                                      /* Set Tx ID value - standard */

  error=CAN1_ReadFrame(MyCANPtr2,0,&FrameR);                   /* Sends the data frame over buffer 1 */

  DataFrameRxFlg = FALSE;

  }

It should continue reading the id infinite time, but it only do it one time, do I need to clear a flag or do i need to do something else to continue reading?

Also for the part of the ID, I am interested in just reading one specific ID. What do I need to configure to the MSCAN_CANIDAR, MSCAN_CANIDMR, MSCAN_RSIDR register to read only the id 0x7E8?

Regards,

Emilio

0 Kudos

963 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Emilio,

-In the function of "CAN1_ReadFrame()" have clear  the Rx flag:

pastedImage_0.png

Clearly the flag of the register MSCAN_CANRFLG to have a try.

- The ID length  of 0x7E8 is lager than 11, so here only can use the Extended ID .

I refer to the Reference manual to calculate it , you can also try to calculate and check whether

is right about mine  the result is

MSCAN_CANIDAR0 = 0x00;

MSCAN_CANIDAR1 = 0x18;

MSCAN_CANIDAR2 = 0x0f;

MSCAN_CANIDARn = 0x00;

MSCAN_CANIDMRn(n=0,1,2,3,) = 0x00;

pay attention that , i assumption you use the data frame , not the remote frame, it is said

the bit of  RSRTR on the register of MSCAN_RSIDR1 is "0".

Hope is helps

Alice

0 Kudos

963 Views
emilioaronmoyer
Contributor III

Hello Alice,

It continue doing the same, doing the reading just one time. what other thing can be?

Regards,

Emilio

0 Kudos

963 Views
emilioaronmoyer
Contributor III

Hello Alice,

I refered to the demo code and the code needs the method

0 Kudos