How to use FLEXCAN RRS?

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

How to use FLEXCAN RRS?

ソリューションへジャンプ
625件の閲覧回数
SaLan
Contributor II

Hi, If I want to use CTRL2[RRS], how should I configure it? I'm testing whether I can receive remote frames for all ID.So I need to configure it in this way and let the CPU perform the corresponding operations. Could you provide me with an example of using CTRL2[RRS]?

Thank you.

SaLan

タグ(1)
0 件の賞賛
返信
1 解決策
493件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport

Hi@SaLan

I made a demo for your reference, the RRS is set to 1, and will send ID 0x100 frame back if received remote frame with ID 0x105.

Senlent_0-1760346864852.png

元の投稿で解決策を見る

0 件の賞賛
返信
10 返答(返信)
600件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport

Hi@SaLan

I not sure which MCU part number you're using right now, suppose you're using S32K1xx.

So if RRS is set to 1, the highlight explained very clear, it will be treated like data frames but will no automatic generate remote response frames.

Senlent_0-1760177030913.png

 

0 件の賞賛
返信
547件の閲覧回数
SaLan
Contributor II
Yes, I understand. I want to confirm which CS code I should set in order to receive the data correctly.
Here is my code example. Could you please help me identify where the problem lies?
If possible, could you please provide an example of how to correctly receive RRS using SDK?
uint8_t CAN0_RXREMOTE_RRS_Test()
{
uint8_t data[1];
FLEX_CAN0_Config0.is_rx_fifo_needed=false;
FLEX_CAN0_Config0.max_num_mb=32;
FLEX_CAN0_Config0.num_id_filters=FLEXCAN_RX_FIFO_ID_FILTERS_8;
FLEX_CAN0_Config0.transfer_type=FLEXCAN_RXFIFO_USING_INTERRUPTS;
FLEXCAN_DRV_Init(INST_FLEX_CAN0, &FLEX_CAN0_State0, &FLEX_CAN0_Config0);
FLEXCAN_DRV_SetRxMaskType(INST_FLEX_CAN0, FLEXCAN_RX_MASK_GLOBAL);
FLEXCAN_EnterFreezeMode(CAN0);
CAN0->CTRL2 = (CAN0->CTRL2 & ~CAN_CTRL2_EACEN_MASK) | CAN_CTRL2_EACEN(1);
CAN0->CTRL2 = (CAN0->CTRL2 & ~CAN_CTRL2_RRS_MASK) | CAN_CTRL2_RRS(1);

CAN0->RXMGMASK = 0xC0000000;
CAN0->RX14MASK = 0xC0000000;
CAN0->RX15MASK = 0xC0000000;
FLEXCAN_ExitFreezeMode(CAN0);
flexcan_data_info_t RxdataInfo =
{
.data_length = 1U,
.msg_id_type = FLEXCAN_MSG_ID_STD,
.enable_brs = false,
.fd_enable = false,
.fd_padding = 0U,
.is_remote = true
};
for(int i = 0; i<32; i++){
data[0]=i;
FLEXCAN_DRV_ConfigRxMb(INST_FLEX_CAN0, i, &RxdataInfo, i);
}
while(1)
{

/* Define receive buffer */
flexcan_msgbuff_t recvBuff;
for(int i = 0 ; i<32 ; i++)
{
FLEXCAN_DRV_Receive(INST_FLEX_CAN0, i, &recvBuff);
while(FLEXCAN_DRV_GetTransferStatus(INST_FLEX_CAN0, i) == STATUS_BUSY);
PINS_DRV_TogglePins(PTD, (1 << 15));

}

}
}
0 件の賞賛
返信
538件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport

Hi@SaLan

I will take time to make a similar demo for your reference.

Please tell me the IDE and the SDK version you're using right now.

0 件の賞賛
返信
535件の閲覧回数
SaLan
Contributor II

Hi,Senlent

I use S32DS.3.4
Thank you!!

0 件の賞賛
返信
521件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport

Hi@SaLan

RRS bit is set to 0 default, so you can just use this api:

"FLEXCAN_DRV_ConfigRemoteResponseMb(instance, mb_idx, &txMsg);"

Senlent_0-1760339181072.png

If you want to set RRS to 1, then just receive it like normal data frames.

 

 

0 件の賞賛
返信
518件の閲覧回数
SaLan
Contributor II

Hi,Senlent
How can I receive it like normal data frames.
When I set RRS to 1,while(FLEXCAN_DRV_GetTransferStatus(INST_FLEX_CAN0, i) == STATUS_BUSY);not working.
I would like to know when I received this CAN frame.
And after that, I can perform operations such as making judgments.
I need a Demo for receive when RRS = 1 .
Thank you
SaLan

0 件の賞賛
返信
494件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport

Hi@SaLan

I made a demo for your reference, the RRS is set to 1, and will send ID 0x100 frame back if received remote frame with ID 0x105.

Senlent_0-1760346864852.png

0 件の賞賛
返信
447件の閲覧回数
SaLan
Contributor II

Hi Senlent

Thank you for your answer, which has been of great help to me.
I want to set the global mask RTR bit and IDE to receive remote frames. However, I found that using your configuration is not able to receive them.
Then, after I configured RTR=1 in the MB, I was able to only receive remote frames.

Due to the incomplete configuration of the library functions in the SDK for MB and global mask, in reality your example only performs the corresponding logical judgment based on the ID.

As shown in the figure, I used your DEMO. In fact, for both data frames and remote frames, as long as the ID is 0x105, they will be received. I think this is not very rigorous.
My suggestions are as follows:
If you want to accurately receive remote frames, the following configuration is required

/*RRS = 1*/
FLEXCAN_EnterFreezeMode(CAN0);
 
/*Set global mask (IDE and RTR)*/
CAN0->RXMGMASK = 0xC0000000;
CAN0->RX14MASK = 0xC0000000;
CAN0->RX15MASK = 0xC0000000;
 
CAN0->CTRL2 = (CAN0->CTRL2 & ~CAN_CTRL2_EACEN_MASK) | CAN_CTRL2_EACEN(1);
 
/* Enable Global RX masking */
CAN0->CTRL2 = (CAN0->CTRL2 & ~CAN_CTRL2_RRS_MASK) | CAN_CTRL2_RRS(1U);
 
FLEXCAN_ExitFreezeMode(CAN0);
And must set MB(RTR=1).Then you can only receive the remote frames and then perform logical judgment processing.
(The above examples are only applicable to the global mask. If you wish to set a specific MB, you need to configure the corresponding RXIMR.)
0 件の賞賛
返信
403件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport

Hi@SaLan

Global or Individual setting is optional.( you can take a look at this article)

https://community.nxp.com/t5/S32K-Knowledge-Base/S32K1xx-FlexCAN-Mask-Setting-Demo/ta-p/1519753

The demo I made only used the Global mask setting to demonstrate the configuration of RRS bit 1.

 

0 件の賞賛
返信
399件の閲覧回数
SaLan
Contributor II

Hi Senlent
Thank you for your help. I have solved the problem now. The examples of mask also helped me.

Thank you!

SaLan

0 件の賞賛
返信