I mentioned in another thread that I began by using the ASF USB UART project as a basis for my project but then ran out of ram when adding my own code so I began migrating to a non-ASF code base. In this process I'm noticing that my DFLL clock accuracy seems to be different. At first it was really noticeable but now it seems to drift in and out of 48MHz. Last night I wrote some code to use TC1 clocked from the DFLL to measure a 60pps reference every 15 seconds for 3 hours, this was the result:
And the Histogram:
I went back and ran both programs to compare the DFLL Registers, this was the result:
So I do notice that the FSTEP and CSTEP registers are different, I've made that change and need to re-test but I'm still curious if there is a better strategy for using DFLL. This board does not have the capability of using an external xtal. Right now it is USB connected but it would be ideal to have something that works without USB too. In general I am curious if something like the internal OSC32 can be used as a reference and if that improves things? When I try to set that up, the chip just goes into reset :(
BTW, here is my current clock code:
uint32_t coarse, fine; SYSCTRL->OSC8M.bit.PRESC = 0; SYSCTRL->INTFLAG.reg = SYSCTRL_INTFLAG_BOD33RDY | SYSCTRL_INTFLAG_BOD33DET | SYSCTRL_INTFLAG_DFLLRDY; NVMCTRL->CTRLB.bit.RWS = 2; coarse = NVM_READ_CAL(DFLL48M_COARSE_CAL); fine = NVM_READ_CAL(DFLL48M_FINE_CAL); SYSCTRL->DFLLCTRL.reg = 0; // See Errata 9905 while (0 == (SYSCTRL->PCLKSR.reg & SYSCTRL_PCLKSR_DFLLRDY)); SYSCTRL->DFLLMUL.reg = SYSCTRL_DFLLMUL_MUL(48000); SYSCTRL->DFLLVAL.reg = SYSCTRL_DFLLVAL_COARSE(coarse) | SYSCTRL_DFLLVAL_FINE(fine); SYSCTRL->DFLLCTRL.reg = SYSCTRL_DFLLCTRL_ENABLE | SYSCTRL_DFLLCTRL_USBCRM | SYSCTRL_DFLLCTRL_MODE | SYSCTRL_DFLLCTRL_CCDIS; while (0 == (SYSCTRL->PCLKSR.reg & SYSCTRL_PCLKSR_DFLLRDY)); GCLK->GENCTRL.reg = GCLK_GENCTRL_ID(0) | GCLK_GENCTRL_SRC(GCLK_SOURCE_DFLL48M) | GCLK_GENCTRL_RUNSTDBY | GCLK_GENCTRL_GENEN; while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY);
I really appreciate the 2nd set of eyes that this forum offers!