s32k312, About CAN Communication on Multi Tasking environment

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

s32k312, About CAN Communication on Multi Tasking environment

1,250件の閲覧回数
jwjung
Contributor II

hi

 

i'm using s32k312 chips.

i'm trying to send the multi message via CAN port using Queue structure.

 

(i'm switching the TASK using the binary semaphore.)

i created 3 TASK and try to use Queue Library.(one thing be used to release the semaphore)

 

TASK1, create the the queue using

static QueueHandle_t QUEUE;  // global variable

Queue = xQueueCreate(10, 16);

 

typedef struct{

           uint32_t id;

           uint8_t length;

           uint8_t data[8];

}CAN_DATA;

 

CAN_DATA CANTxData;

 

TASK2, insert item into the Queue using xQueueSendToBack(QUEUE, &CANTxData, 0);

 

buf = {52, 0, 1, 0, 0, 0, 1, 0}, id = 0x601, length = 8. -> CAN_DATA CAN_1 value

buf1 = {0, 0, 0, 0, 1, 1, 0, 20}, id = 0x600, length = 8. -> CAN_DATA CAN_2 value

 

 

xQueueSendToBack(CAN_QUEUE, CAN_1, 0);

xQueueSendToBack(CAN_QUEUE, CAN_2, 0);

 

vApplicationIdleHook(){

  CAN_DATA *CANRxDATA;

  BaseType_t status;

 

 status = xQueuePeekFromISR(CAN_QUEUE, &CANRxDATA);

 if (status == pdTRUE){

   status = xQueueReceiveFromISR(CAN_QUEUE, &CANRxDATA, NULL);

      if (status==pdTRUE){

           Flexcan_Ip_DataInfoType message_Type = 

                   {

                          .msg_id_type  = FLEXCAN_MSG_ID_STD,

                          .data_length = CANRxDATA -> length,

                          .is_polling = FALSE,

                          .is_remote = FALSE

              };

              Flexcan_Ip_Send(INST_FLEXCAN_2, CAN2_TXMAILBOX, &message_type, CANRxDATA -> id, (uint8_t *) CANRxDATA -> data);

      }

}

}

 

FlexCAN configuration is 

 

 

(platform.os.freertos : 1.0.0)

And FreeRTOS peripheral configuration is

in section QUEUE,

queue registry size : 2

(the check box)disable use queue sets.

 

in this configuration, i release the F/W and return the CAN Value like

0x600, data[8] = 00 00 00 00 01 01 00 14, length : 8.

don't response the CAN_id is 0x601.(the last input item be responsed)

 

in addition i changed xQueueSendToFront , but result is same.

through debugging, i confirm the ucWatingMessage set 2, and the memory address be changed. (with yellow below)

 

if i wanna send the CAN Data(2 or more message in time) with Queue, how can i do for it?

 

let me know the solution about configuration or Code.

0 件の賞賛
返信
4 返答(返信)

1,209件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

if you want to use single MB for sending more messages then you must call Send function after previous one successfully finished. You can check status using FlexCAN_Ip_GetTransferStatus.
Also you can try to use more MBs for transfer.

BR, Petr

0 件の賞賛
返信

1,185件の閲覧回数
jwjung
Contributor II

Thanks to relpy, Petr

 

i change the location of the code like,

 

void vApplicationIdleHook(void){
CAN_TYPE *CANMessageData;
BaseType_t status;
 
// confirm the current first message
status = xQueuePeekFromISR(QUEUE, &CANMessageData);
 
if (status == pdTRUE){
 
if (FlexCAN_Ip_GetTransferStatus(INST_FLEXCAN_2, CAN2_TXMAILBOX) == FLEXCAN_STATUS_SUCCESS){
 
// get data and relesase the resource
status = xQueueReceiveFromISR(QUEUE, &CANMessageData, NULL);
 
if (status == pdTRUE){
 
Flexcan_Ip_DataInfoType message_type = {
.msg_id_type = FLEXCAN_MSG_ID_STD,
.data_length = CANMessageData -> length,
.is_polling = FALSE,
.is_remote = FALSE
};
 
FlexCAN_Ip_Send(INST_FLEXCAN_2, CAN2_TXMAILBOX, &message_type, CANMessageData -> id, (uint8 *)CANMessageData -> data);
}
}
}
}

 

but still didn't work...

0 件の賞賛
返信

1,174件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

what is returned value from Send function? Is a message prepared sent on the bus successfully without error detected? If yes, then message interrupt should be called and driver status variable updated, so next call of FlexCAN_Ip_GetTransferStatus returns success and Send can be called again.

Regards, Petr 

0 件の賞賛
返信

1,169件の閲覧回数
jwjung
Contributor II

Thanks to response, Petr.

 

return value is pdTRUE. and any error be detected in debugging.

but the message be received every 0.3ms not 100ms in PCAN VIEW Window.

and the CAN ID 0x300 be show only(0x310 do not showed)

 

I add the 2 message continuous to Queue. in one block  but last Message be sent in my opinion.

 

how can i add 2 or more message into Queue at once?

0 件の賞賛
返信