Arduino CAN bus SparkFun CAN
Moderator: Benj
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Arduino CAN bus SparkFun CAN
That does sound odd. I suspect the SPI, could you try running it slower, or perhaps change the sample point to “Middle”?
Re: Arduino CAN bus SparkFun CAN
thanks for your reply.
yep, it acts very strange.
what is the setting for running it slower?
yep, it acts very strange.
what is the setting for running it slower?
Re: Arduino CAN bus SparkFun CAN
oh yes, now the setting that was magic came.
Before, with "Sample point End"
then i had to use CheckRx(1) to triger "RX Buffer 0"
now when i change to "Sample point Middle"
then i can use CheckRx(0) to triger "RX Buffer 0"
and now it works.
I will do some more test now.
Before, with "Sample point End"
then i had to use CheckRx(1) to triger "RX Buffer 0"
now when i change to "Sample point Middle"
then i can use CheckRx(0) to triger "RX Buffer 0"
and now it works.
I will do some more test now.
Re: Arduino CAN bus SparkFun CAN
Further test:
Prescale did no difference with Sample point End.
Sample point Middle did it.
now it works
Prescale did no difference with Sample point End.
Sample point Middle did it.
now it works
Re: Arduino CAN bus SparkFun CAN
Great thanks!!
Next question.
GetRxIDLo function:
when i send ID 0x1 with my CAN analyser
GetRxIDLo returns 20 (hex)
when i send ID 0x2 with my CAN analyser
GetRxIDLo returns 40 (hex)
when i send ID 0x3 with my CAN analyser
GetRxIDLo returns 60 (hex)
Next question.
GetRxIDLo function:
when i send ID 0x1 with my CAN analyser
GetRxIDLo returns 20 (hex)
when i send ID 0x2 with my CAN analyser
GetRxIDLo returns 40 (hex)
when i send ID 0x3 with my CAN analyser
GetRxIDLo returns 60 (hex)
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Arduino CAN bus SparkFun CAN
If you hover your mouse over the function names of the CAN component in the Project Explorer you will see the hint text.
The GetRxIDLo reads the raw device register, so see the CAN controller datasheet to see the reason for the apparent data shift.
You more likely need to use GetRxIdent instead of GetRxIDLo/Hi
The GetRxIDLo reads the raw device register, so see the CAN controller datasheet to see the reason for the apparent data shift.
You more likely need to use GetRxIdent instead of GetRxIDLo/Hi
Re: Arduino CAN bus SparkFun CAN
All tested, works perfect!
Now next question that i have got into.
I have 2 shields, as you can see ealier in this tread.
it works to send from CAN1 -> CAN2.
and I should also send from CAN2 -> CAN1
but when i send from CAN1 -> CAN2, then i guess that it goes into the buffer of CAN2? and this will be triggered to send back to CAN1 then,
and then i have a loop.
I was thinking that before i send from CAN1 -> CAN2, then i would switch off CAN2 RX Buffer0
and then when i have sent, then i switch it on again.
what settings should i do? I currently have Accept all.
But Accept all, and reject all, this i cant put into this box:
Now next question that i have got into.
I have 2 shields, as you can see ealier in this tread.
it works to send from CAN1 -> CAN2.
and I should also send from CAN2 -> CAN1
but when i send from CAN1 -> CAN2, then i guess that it goes into the buffer of CAN2? and this will be triggered to send back to CAN1 then,
and then i have a loop.
I was thinking that before i send from CAN1 -> CAN2, then i would switch off CAN2 RX Buffer0
and then when i have sent, then i switch it on again.
what settings should i do? I currently have Accept all.
But Accept all, and reject all, this i cant put into this box:
- Attachments
-
- SetBufferCAN2.PNG (92.97 KiB) Viewed 3405 times
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Arduino CAN bus SparkFun CAN
To accept all, just set the mask to 0
To reject all, set the mask to 0x7ff (in the case of standard IDs) and the filter to 0
e.g. SetRxMask(0,0x7ff) and SetRxFilter(0,0)
A read of the Microchip CAN controller datasheet is well worth the time.
You will need this to understand which mask each filter is associated with, and how these work.
To reject all, set the mask to 0x7ff (in the case of standard IDs) and the filter to 0
e.g. SetRxMask(0,0x7ff) and SetRxFilter(0,0)
A read of the Microchip CAN controller datasheet is well worth the time.
You will need this to understand which mask each filter is associated with, and how these work.