Author Topic: SAM ASF clock generation for cpu  (Read 1701 times)

0 Members and 1 Guest are viewing this topic.

Offline hsn93Topic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: bh
SAM ASF clock generation for cpu
« on: July 05, 2018, 09:42:30 am »
hello, i've a board that has SAMD21 MCU and i was trying to run it on 48MHz using ASF but i couldnt i researched for different projects they are using 8mhz even the rtc example is using 8mhz of cpu clock ..

i found different people saying this post helped them but the url is broken:
 http://atmel.force.com/support/pkb_mobile#/articles/en_US/FAQ/How-to-configure-DFLL48M-oscillator-as-main-clock-in-ASF-project-for-SAMR21-SAMD21-SAMD20-SAMD10-SAMD11

here is my ASF configurations:
cpu clock source [GCLK0]:




after i upload my code the cpu doesnt work because i know when i set it back to 8mhz the led toggles.

so i 've looked into fuses which are called (NVM user row mapping) didnt find any clock selection so i didnt program any fuses..
« Last Edit: July 05, 2018, 09:45:35 am by hsn93 »
-------------------------------------
 

Offline hsn93Topic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: bh
Re: SAM ASF clock generation for cpu
« Reply #1 on: July 05, 2018, 10:59:07 am »
now the most wierd thing is this:

i enable the 32 internal high accuracy osc


and regenerate asf files and the code doesnt work.. i didnt change anything .. the internal osc is actually not used .. so i would say somewhere the MCU get stuck related to using different oscillator than 8MHz?
-------------------------------------
 

Offline hsn93Topic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: bh
Re: SAM ASF clock generation for cpu
« Reply #2 on: July 05, 2018, 12:13:19 pm »
the problem is related to NVM wait states, when i set it to "1" instead of default "0" the cpu doenst hang..

i dont know how, why, how it works..

but i just wanted to post this reply

 if anyone would like to comment that would help me thank you..
« Last Edit: July 05, 2018, 12:55:13 pm by hsn93 »
-------------------------------------
 

Offline Lajon

  • Contributor
  • Posts: 31
  • Country: se
Re: SAM ASF clock generation for cpu
« Reply #3 on: July 05, 2018, 01:08:35 pm »
From the posted clock config pictures it does not look like you got any clock at 48 MHz but I guess you now have clock generator 0 at 48 MHz and then needed to add wait states? This is expected, check "NVM Characteristics" under "Electrical Characteristics" in the datasheet.

USB host examples will have a clock generator at 48 MHz btw (even if it's not clock generator 0).
/Lars
 
The following users thanked this post: hsn93

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11248
  • Country: us
    • Personal site
Re: SAM ASF clock generation for cpu
« Reply #4 on: July 05, 2018, 04:45:24 pm »
the problem is related to NVM wait states, when i set it to "1" instead of default "0" the cpu doenst hang..
i dont know how, why, how it works..
Well, flash can't work at 48 MHz. Wait states slow it down. See Table 37-40. Maximum Operating Frequency
Alex
 
The following users thanked this post: hsn93

Offline hsn93Topic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: bh
Re: SAM ASF clock generation for cpu
« Reply #5 on: July 08, 2018, 05:29:42 am »
thank you, its more clear now @ataradov , @lajon

Quote
USB host examples will have a clock generator at 48 MHz btw (even if it's not clock generator 0).
yeah but as much as i understand its only for peripheral of usb .. cpu is still at 8 MHz and that wait states is 0 in them.
-------------------------------------
 

Offline Lajon

  • Contributor
  • Posts: 31
  • Country: se
Re: SAM ASF clock generation for cpu
« Reply #6 on: July 08, 2018, 05:55:18 pm »
Yes, it was only a suggestion for anyone in need of a start example that sets up a 48 MHz clock generator, moving it from generator n to 0 should be trivial.
/Lars
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf