SAMD21 External clock stuck in initialization

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using a custom board based on samd21j18a mcu, the board embeds an external oscillator and it is working fine when using asf3, whereas it fails to initialize clock when using asf4.

It gets stuck in this while loop in hpl_sysctrl.c file.

 

#if CONF_XOSC_CONFIG == 1
#if CONF_XOSC_ENABLE == 1
    while (!hri_sysctrl_get_PCLKSR_XOSCRDY_bit(hw))
        ;
#endif

 

Here is my clock config in START:

ATMEL START CLOCK CONFIG SCREENSHOT

 

I searched everywhere onilne for the problem but can't seem to find a solution.

Cheers.

This topic has a solution.

wubalubadubdub

Last Edited: Thu. Feb 20, 2020 - 01:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not enough of the config is shown above, maybe you have this problem:

https://community.atmel.com/forum/xplained-pro-samd21-external-crystal

/Lars

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for replying.

I solved the problem by setting the following configs:

in hpl_sysctrl_config.h:

#define CONF_XOSC32K_ONDEMAND 0
#define CONF_XOSC32K_XTALEN 1
#define CONF_XOSC_ONDEMAND 0
#define CONF_XOSC_XTALEN 1

and this only works if I set nvm wait state to 1 (by default 0) in hpl_pm_config.h:

#define CONF_NVM_WAIT_STATE 1

I attached my config folder below if it can help someone in the future.

Attachment(s): 

wubalubadubdub

Last Edited: Thu. Feb 20, 2020 - 10:28 AM