Hi,
my teste bus with 10 IDs.
how to set filter to: read 3 ID/10 ID?
ex:
read ID: 0x7E0,0x7E1,0x7E2, others IDs not read.
500khz, interval between frames = 90uS.
how to ISR use filter for the ID must read.
simple cmp not have timer!
if( ID == ID[i] )
save
else
not save
my test with K70.
thanks
Carlos.
Solved! Go to Solution.
Hi Zhou,
thank you for your help.
Solved Invidual acceptance mask filter.
see:
calc_id_mask
uint mask = your_id ; // 0001-1111-1111-1100-0000-0000-0000-0000
mask = mask << 18;
mask |= 0x3FFFF; < ---Acceptance mask invidual
//-----------------------------------------
void CAN1_OnFullRxBuffer(LDD_TUserData *UserDataPtr, LDD_CAN_TMBIndex BufferIdx)
{
simple
switch( BufferIdx){ read buffer_x }
}
//-----------------------------------
Thanks,
Carlos.
Hi Carlos candido,
Thank you for your more information.
I already help you create a K70 KDS CAN_LDD project, you can refer to my project, the CAN_LDD configuration is like following:
Because you want to receive the standard ID:0x7E0,0x7E1,0x7E2
the standard ID is 11bit, it is:
0x7e0: 11111100000
0x7e1: 11111100001
0x7e2: 11111100010
Then, you can use the acceptance mask to care all the higher 9 bit ID, and don't care the lower 2bit.
so you can configure the acceptance mask for buff(register CAN1_RXMGMASK) = 0x1ff3ffff, you can combine the Rx FIFO structure in RM to understand it:
Actually, if you don't care the lower 2 bit of the standard ID, you can receive just 0x7E0,0x7E1,0x7E2, 0x7e3, then all other standard ID won't be received.
I already test my project on my TWR-K70F120M, the test result is like following:
You will find 0x7E0,0x7E1,0x7E2 can be received by the K70, but the 0X123 will be reject.
More details, please refer to my attached project.
Wish it helps you!
If you still have question, please let me know!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Zhou,
thank you for your help.
Mode : 1
Golbal Acceptance Mask, Buffer 0...N = ok
Mode :2
Invidual Accptance Mask = not run all ID
see:
my_function_calc_mask()
{
uint mask = 0x7C4;
uint xor = 0x1FFFFFFF;
uint accep = 0x1FFFFFF; // 0001-1111-1111-1100-0000-0000-0000-0000
mask = mask << 18;
mask |= 0x3FFFF; < ---Acceptance mask ividual
}
note:
Buffer:0 0x7C1 = ok
Buffer:2 0x7C2 = not accepted
Buffer:3 0x7C3 = ok
Buffer:4 0x7C4 = not accepted
buffer_zero defined all masks.
thanks,
Carlos.
Hi Zhou,
thank you for your help.
Solved Invidual acceptance mask filter.
see:
calc_id_mask
uint mask = your_id ; // 0001-1111-1111-1100-0000-0000-0000-0000
mask = mask << 18;
mask |= 0x3FFFF; < ---Acceptance mask invidual
//-----------------------------------------
void CAN1_OnFullRxBuffer(LDD_TUserData *UserDataPtr, LDD_CAN_TMBIndex BufferIdx)
{
simple
switch( BufferIdx){ read buffer_x }
}
//-----------------------------------
Thanks,
Carlos.
Hi Carlos candido,
Please tell me which IDE you are using? and the ID type is standard or extend ID?
Waiting for your reply!
Jingjing
Hi Zhou,
I use IDE KDS30.
Type ID Stander.
Twr-K70F.
Thanks
Carlos