-
Notifications
You must be signed in to change notification settings - Fork 8.2k
sam: atsamc21: driver for CAN for SAMC21 #50408
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
Conversation
henrikbrixandersen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need a way of testing this - at least the compilation part. Can this be enabled on a board?
This CAN works only with SAMCAN21x. I have in my solution connected to board intruduced at #50384 PR. BTW In my repo it fully works. You can check my old commit: benys@55559a8 |
|
Okay. I suggest postponing this to after #50384 is merged, then. That was the initial feedback given in that PR as well. |
|
Please provide a meaningful commit message |
|
Converted to a draft for now, as board files still need to be added after #50384 was merged. |
|
@henrikbrixandersen i have a problem, that CAN can send messages (i receive messages by CAN usb stick), but when I send by CAN usb stick - i don't receive interrupt. Do you have idea what I have to check? |
First off, do the CAN API tests pass in loopback mode? Once the CAN API tests pass in loopback mode - and if the problem persists:
|
Not yet, but I run sam counter sample. And I extend it a litte bit. On loopback mode it fully works. With external CAN commands it not handle incoming CAN frames.
I tripled checked. I honestly I port my application which originaly used plain ASF4. So I checked pinctrls by comparison one-to-one. TXpin works becouse it send data. SO i believe that in in zephyr RXpin also is corecrly connected.
Yes, but I have idea that problem is that zephyr mcan driver uses two interrupts per device, but SAMC has only one line. I tried investigate, that maybe mcan driver set to use second interrupts for incoming data from external world.
Yes for example:
Yes :-) without debugger it is inposible to investigate :) I will try check with second interupt for bosch IP. If you have some ideas please give me :) |
|
Looks like the loopback mode works. |
|
@henrikbrixandersen and @alexanderwachter i think that i found I receive some of messages. in mcan driver was implemented that some interrupts was handled by second line. BTW i need now investiage why have many bus_off state. |
You can add that for now. I am working on getting rid of all platform specific code in the M_CAN backend driver, though. |
|
@henrikbrixandersen @alexanderwachter i had last problem (i hope). NBTP computation. generation from zephyr
so
my original sample
so
But first sample - produces a lot of receive errors (counter is not zero) and my second samples works very well. |
|
Well, you can set the sample point a bit earlier to meet your old values. However, the sample points used by Zephyr are recommended by the CiA |
|
@benys can you rebase please? |
bdf0893
bdf0893 to
be71b32
Compare
I rebased, but I will it test +- tommorow at the office :) I will inform you. |
3f0a940 to
782c99f
Compare
|
I tested the code before rebase and after rebase on my very reputable hardware (https://ww1.microchip.com/downloads/en/DeviceDoc/70005318A.pdf) and I have some observations.
|
|
@silverv @henrikbrixandersen i little fixed my PR, but after rebase still not works :-( EDIT: EDIT2 @henrikbrixandersen I don't know that I can include it at my change? Or remove static attribute can_mcan_enter_init_mode to execute it form sam0 driver level |
fa21a9c to
47b072e
Compare
Driver was based on can_sam. SAMC21 has only 1 interrupt for one can "output", so can interrupt has to executes two lines of interrupts. CAN is configured to use OSC48M clock via GLCK7. GLCK7 is set by divider configured from dts. Signed-off-by: Kamil Serwus <[email protected]>
Enable CAN driver sam0 in SAMC21 socs. CAN module exists only in C21 socs. Signed-off-by: Kamil Serwus <[email protected]>
Configure pinmux pins at samc21 xpro board. Boards has hard-configured pins for CAN0 and CAN1 module. Signed-off-by: Kamil Serwus <[email protected]>
SAM0 required can module was in init state before configure pointers to ram which handle can frames. Signed-off-by: Kamil Serwus <[email protected]>
henrikbrixandersen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!

Driver was based on can_sam.
Signed-off-by: Kamil Serwus [email protected]