Help with samd21 external crystal Weird behaviour using Atmel Start

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

Hi, so i have a samd21j16b, with a 32khz external crystal.

on setup if i have the tick on Exterla 32K Oscillator Enable, it won't start, it gets stuck waiting for PCLKSR.XOSC32KRDY. If i don't put the tick, it skips that comprobation and it start without problems.

#if CONF_XOSC32K_CONFIG == 1
#if CONF_XOSC32K_ENABLE == 1
    while (!hri_sysctrl_get_PCLKSR_XOSC32KRDY_bit(hw))
        ;
#endif
#if CONF_XOSC32K_ONDEMAND == 1
    hri_sysctrl_set_XOSC32K_ONDEMAND_bit(hw);
#endif
#endif

 

I have made a code where i'm placing the clock input to GCLK_GEN_2 and then to an external pin(with function H), and when i measure with osciloscope i read 32.890 kHz(have to play with the capacitors to adjust it later).

 

So it seems to be working just fine. Even if PCLKSR.XOSC32KRDY never sets.

 

What is the problem here? why PCLKSR.XOSC32KRDY never sets? i need ultra precision for it to set? 32.768kHz? or is just a problem with atmel code or chip?

This topic has a solution.
Last Edited: Wed. May 25, 2022 - 01:28 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi 

 

Not sure if this helps, but I am using SAMD51 with an external 32KHz clock and this is my setup which is working fine.

Maybe if your capacitors values are a bit off the clock might be slow to start-up so increasing the start-up delay to the max might show this?

 

External 32k clock setup

Kevin

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


i'm probably using other version of Atmel Studio.

 

with this configuration it doesn't work:

 

 

with this one it works:

 

Could the problem be the type of crystal? i'm using:

           MS1V-T1K    32.768kHz 7pF +/-   20PPMTA

           (32k768 crystal, +-20ppm, CL=7pF,max ESR 60kOhm, SMD)

The crystal and caps are as close as possible to the xin32 xout 32pin.

I dindn't start this proyect, so the board was already design and ensambled, they used 6.8pF ceramic capcacitors, NOP, 50v, +-5%.  They copy this part from another project online that used the same chip. From my calculus, we need 10.8~11pf capacitors to get 32.768kHz.

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

nvm, now with my head more clear, i read the documentation again, and saw that the xtal register is the one that selects between crystal and clock, why would they made so confusing the enables names on start.

I thought the part where you selected it was External 32k Oscillator Enable, not Enable XTAL. By luck i re read that part with the Xtal register name on the datasheet and remebered there was a Xtal ooption on start config.

And now, the oscillation is even 32.768kHz, probably when enable correctly as crystal, the internal capacitance corrected.

 

Problem Solved.

Last Edited: Wed. May 25, 2022 - 01:35 PM