-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dual CAN #1
Comments
Theoretically if you make a different object for each one. That being said, I have not ever tried it. |
I tried pointing samc21_can.cpp to the new pins for the second CANbus (PB10 & PB11 on a C21G) and group with no response. Also tried the same in Atmel Studio with no luck. I can't find any example from Atmel or otherwise of the second CANbus channel working. |
Yeah, looking at this again it is going to take some work to even make it work easily with CAN1, let alone with both at the same time. I can start looking into it, but I am really busy right now. I don't know how long it might take me. |
…different pins. It might allow both CAN to be used.
… hard coded it that way. This way only the TX pin needs to be specified. The software expects a pair to be used like that and currently doesn't support a split port.
I modified it so that you should be able to specify CAN0 or CAN1, and set the pins to use. Only the TX pin needs to be specified because the software currently can only deal with the pins as a pair. I don't have an easy way to test that this works with CAN1. I can only tell you that it works as it used to with CAN0. Please let me know if it works for you. |
Thanks, I will try this tomorrow. For my CAN0 I am using PB22 & PB23 so in the old code I had to change: |
That's what I get for doing it so quickly. Thanks for pointing it out. It now has a group argument for the constructor. |
Hello, firstly thank you for your work, but CAN1 does not work out of the box and I need it for my project:) I would love to help get the lib tested with CAN1, can you provide me with a theoretical working example for CAN1 use? Thank you! |
Can you try changing line 101 in samc21_can.cpp to: GCLK->PCHCTRL[CAN1_GCLK_ID].reg = GCLK_PCHCTRL_CHEN | GCLK_PCHCTRL_GEN_GCLK0; |
Also, the cantx parameter would be 10 for PB10, with a group of 1. PORT_PB10 is a bit mask, not a pin number. |
Thank you for your quick reply! The initialization now works, but there is nothing happening on pin PB10 (it's just high). I used SAMC21_CAN can(0, ID_CAN1, PIN_PB10, 1); |
Yes setting the cantx parameter to 10 is now switching the value and CAN1 seems to be working! |
Glad to hear it!
I am not sure what you are trying to get at here. |
Well each group starts with 0 for pin numbers, the PORT_PB10 is 1024 meaning the pin is numbered as 10 in group B. But the PIN_PB10 constant is absolute across ports and is 42 and should be converted to the per port value in its group, which is 10, when accessing specific group registers. So the working init is now: And if you wanted to use PIN_PB10 (for any group>0) you would have to convert to group specific numbering in the library. |
I could do that, but I will have to make sure I don't break the current API. |
Well to keep the api oblivious to ports you could get the pins group from the wiring: Or keep the API the same, but either way you would have to convert the pin's absolute number to its group specific number, like digitalWrite does: Thanks again for your efforts. |
I moved the API change to bug #4 as it is not within the scope of this bug. |
Hi, the SAMC21 has 2 CAN ports - will this work with both at the same time?
The text was updated successfully, but these errors were encountered: