loosing sporadic some can-messages when using FLEXCAN_DRV_Send()

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

loosing sporadic some can-messages when using FLEXCAN_DRV_Send()

1,660件の閲覧回数
manuel_kauf
Contributor II

Hi,

I lose sporadic tx messages on the FlexCAN. There are two different impacts:

  • I get a "STATUS_BUSY" from the FLEXCAN_DRV_Send() function. The message was not sent, so there is no interrupt (void FLEXCAN_IRQHandler(uint8_t instance)) that can set the message box back to idle.
  • I get no error at all.


The misbehavior has nothing to do with the can-identifier or number of the message box  It gets worse with high busload.

My remote unit (Vector CANoe and VN1610) checks the sequence as well as the crc / counter for plausibility. And some Messages are just lost. I double checked with an oscilloscope, the messages are not on the bus.

my Setup:

I use a S32k144 with SDK 4.2 (Configured with S32k Studio), baud is 500k. I send 10 tx messages and receive 6 rx messages. Each tx message has its own MessageBox. RxFifo is used.
My tx MB start at 16 and i configured CAN_CTRL1_LBUF(1U) (i need a fixed transmit order)

MB 16 all 20ms ( ID= 100 Message1 )
MB 17 all 20ms ( ID= 101Counter and CRC of Message 1)
MB 18 all 20ms ( ID= 120 Message2 )
MB 19 all 20ms ( ID= 121 Counter and CRC of Message 2)
MB 20 all 20ms ( ID= 140 Message3 )
MB 21 all 20ms ( ID= 141 Counter and CRC of Message 3)
MB 25 all 20ms ( ID= 160 Message4 )
MB 27 all 20ms ( ID= 161 Counter and CRC of Message 4)
MB 29 all 500ms ( ID= 200 Message5 )
MB 30 all 500ms  ( ID= 201 Counter and CRC of Message 5)


CanConfig:

.fd_enable = false,
.pe_clock = FLEXCAN_CLK_SOURCE_OSC,
.max_num_mb = 32,
.num_id_filters = FLEXCAN_RX_FIFO_ID_FILTERS_8,
.is_rx_fifo_needed = true,
.flexcanMode = FLEXCAN_NORMAL_MODE,
.payload = FLEXCAN_PAYLOAD_SIZE_8,
.bitrate = {
.propSeg = 7,
.phaseSeg1 = 4,
.phaseSeg2 = 1,
.preDivider = 1,
.rJumpwidth = 1
},
.bitrate_cbt = {
.propSeg = 7,
.phaseSeg1 = 4,
.phaseSeg2 = 1,
.preDivider = 1,
.rJumpwidth = 1
},
.transfer_type = FLEXCAN_RXFIFO_USING_INTERRUPTS,
.rxFifoDMAChannel = 0U


Installed Error Callback

FLEXCAN_DRV_InstallErrorCallback(INST_CANCOM0, (flexcan_error_callback_t)flexcan_callback, &canCom0_State);

flexcan_event_type_t eventType, uint32_t buffIdx, flexcan_state_t *flexcanState)
{
    can_callback_event = eventType;
    callback_error_status = FLEXCAN_DRV_GetErrorStatus(instance);
}

I save the registers (CTRL1, IFLAG1, IMASK1, mb_idx, msg_id, state->mbs[mb_idx].state, ECR, ESR1, ESR2 ) in a trace. However, there are no suspicious things here either.

Does anyone have a tip for me?

ラベル(1)
0 件の賞賛
返信
5 返答(返信)

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

Hi,

can you also share the code you are using for TX MB config and sending?
Once STATUS_BUSY is returned can you check MB's CODE field and MB's IFLAG/IMASK bit value?
What if you decrease CTRL2[TASD] value, do you see any difference?

BR, Petr

0 件の賞賛
返信

1,629件の閲覧回数
manuel_kauf
Contributor II

Hi Petr, 

thanks for your reply. 
The Code for sending is the default

FLEXCAN_DRV_Send(INST_CANCOM0, txMBNr, &dataInfo, id, pData)

 from flexcan_driver.c. 
The init Function is:

FLEXCAN_DRV_Init();

For the MB Init :

    for (uint8_t i=CAN_TX_MB_START; i<CAN_MAX_MB_NUM; i++)
    {
        flexcan_data_info_t dataInfo = BSP_CAN_DATA_INFO;
        success &= STATUS_SUCCESS == FLEXCAN_DRV_ConfigTxMb(INST_CANCOM0, i, &dataInfo, 0);
    }

I tested CTRL2[TASD] down to 1 (default is 0x10) however I have the same errors. I have large gaps on the bus, so the tx should definitely be able to get to it.
My biggest problem, I have no error detection, Is my message sent or not.

The STATUS_BUSY Error is rare, I'll post the info here as soon as it occurs.

0 件の賞賛
返信

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

Hi,

could you send more detail, how often Send function is called for individual MBs? Do you prepare all MBs for TX after last MB is sent or how this is done in your application. Do you check status of the MB before Send is called?
If you'll catch STATUS_BUSY, share the info I mentioned to have more insight into issue.  

BR, Petr

0 件の賞賛
返信

1,597件の閲覧回数
manuel_kauf
Contributor II

Hi Peter,

sorry for my late response i was not at the office

we Send 8 Messages (as descripted in the first post) all 20ms and 2 all 500ms. 
We dont prepare every MB bevore we sent, (this should done by the sdk ISR) we assume that the message was sent out after 20ms. And the SDK driver has a lot of checks before sending.
One Message need ~260µs and we have at least five 1ms gaps on the bus. 
The SDK send function does that check (thats when it sometimes returne with STATUS_BUSY). 

Unfortunately, I currently no longer have the STATUS_BUSY error. Only the quiet one where I only lose the messages, but do not get any information.

best regards,  Manuel

0 件の賞賛
返信

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

Hi,

it should be fine to know status of IFLAG1, IMASK1, state->mbs[mb_idx].state and MB CODE when STATUS_BUSY is returned or message missed.
To know if MB is still prepared for transmission with interrupt enabled or somehow deactivated.
Maybe AbortTransfer can resolve that "lock" condition.

BR, Petr 

0 件の賞賛
返信