Electronics > Microcontrollers

CAN on ATSAMC21J18A

<< < (5/6) > >>

matti.salo:
I didn't find "basic CAN" example only FD, bnut that doesn't help me since i do not have a another FD device.

I have now again gathered example with ASF4 configurator:
Clocks:
[attach=1]
CAN0:
[attach=2]


The main code is only:

--- Code: ---#include <atmel_start.h>

int main(void)
{
/* Initializes MCU, drivers and middleware */
atmel_start_init();

delay_ms(1000);
/* Replace with your application code */
while (1) {

CAN_0_example();
USART_0_example();
delay_ms(200);
gpio_toggle_pin_level(LEDI);
}
}
--- End code ---


The CAN part of my board:[attach=3]

In CAN bus i'm now using PCAN interface as a second device and Picoscope as debug device.
With these settings i get: [attach=4]

If i set just a random time quanta settinks like:
25+25+25:
[attach=5]

What am i'm missing.

matti.salo:
Just after last message i got this to work.

First: 48Mhz clock started to work after adding NVM waits from 0 to 1. thanks to this post:
https://www.avrfreaks.net/forum/samc21-not-running-48mhz-and-96mhz
[attach=1]

Second i added 120ohm resistor to can.
Working setting on ASF are now:
[attach=3]
[attach=2]

ataradov:
I mentioned flash wait states in my original reply.

Example in ASF3 is much better and has both FD and classical example in the same application controllable though serial port menus. Although it looks like that CAN FD demo from ASF4 is the same exact demo.

matti.salo:
Yes, you did mention it, but i did not understand it :) so that was my bad. Configuring clocks is new to me.

I thank you ataradov, without your help i would not got this to work.

Rudolph Riedel:

--- Quote from: matti.salo on October 14, 2021, 12:53:22 pm ---First: 48Mhz clock started to work after adding NVM waits from 0 to 1. thanks to this post:
https://www.avrfreaks.net/forum/samc21-not-running-48mhz-and-96mhz

--- End quote ---

It might work but as the datasheet and the quote in the linked thread says, for 48MHz the SAMC21 needs 2 wait-states, not 1.

Unfortunately Atmel never fully qualified what the ATSAMC2x or ATSAMx5x are capable of and Microchip does not seem to care,
so a lot of these numbers are still based on simulation rather than qualified measurements and so a lot of these Maximum frequency numbers for the various peripheral units look way too conservative.
But if the datasheet states that 48MHz require 2WS I rather configure the controller to 2WS than risking the software to fail in some random way that is impossible to reproduce.

And in this context I wonder why the same CAN-FD module supposedly can only do 48MHz in the ATSAMC21, 100MHz in the ATSAME51 and whatever the limit is for ATSAMx7x as it looks like this information is not given in the datasheet.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version