Problem with Analog Comparator demos on SAM C21 Xplained Pro

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

Hello fellows,

 

I've got a SAM C21 Xplained Pro board. For the life of me, I can't make either SAM Analog Comparator Driver demo code (polled or callback) work correctly.

 

The problem is that in BOTH examples, a hang occurs in a function called ac_is_syncing() which is called by the function ac_enable() in module initialization.

 

The offending line in ac_is_syncing() is a bit-wise AND comparison of the flags:

 

#ifdef FEATURE_AC_SYNCBUSY_SCHEME_VERSION_2
    if (ac_module->SYNCBUSY.reg & AC_SYNCBUSY_MASK) {  /*SYNCBUSY.reg is 0x8 and AC_SYNCBUSY_MASK is 0x7F, so result is 0x8*/
        return true;   /*<<< this is always true, so function just loops indefinitely*/
    }

 

I've tried messing around with clock speeds and wait states, etc, in both examples. No Luck...

 

I've also scoured the documentation, including http://www.atmel.com/Images/Atme....

 

Does anyone have any idea? Is this a known issue?

 

Thanks very much !

 

 

Last Edited: Wed. Mar 15, 2017 - 02:25 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fellows,

 

Since the last post, I've also tried the AC_UNIT_TEST ASF sample project. This also hangs in ac_enable() due to the same issue - never returns from ac_is_syncing()

 

I'm now convinced either there is some problem with my board/silicon, or there is another fundamental error in the driver, as it applies to the C21.

 

Any assistance from the group would be greatly appreciated!

 

 

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

I tried the "Quick Start for the SAM AC driver (polled)" from ASF 3.34.1, it works for me (this is also a SAM C21 Xplained Pro).

/Lars

 

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

Hey,

 

I have the same problems. My program stops at ac_enable().

 

Has anybody solved the problem yet?

 

Greetings,

 

JJJey

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

FYI at anyone else.

 

This is a bug in ASF.

 

 

in \ASF\sam0\drivers\ac\ac_sam_l_c\ac.c

 

You will find:

 

#if (SAMC21) || (SAMC20)

/* The Analog Comparators and ADC1 use the same generic clock configuration.

  * GCLK_ADC1 must be used to configure the clock for AC as GCLK_AC is not 

  * functional. Errata reference: 13404 

  */

system_gclk_chan_set_config(34, &gclk_chan_conf);

system_gclk_chan_enable(34);

#else

system_gclk_chan_set_config(AC_GCLK_ID, &gclk_chan_conf);

system_gclk_chan_enable(AC_GCLK_ID);

#endif

 

 

Change it to

 

#if (SAMC21) || (SAMC20)

/* The Analog Comparators and ADC1 use the same generic clock configuration.

  * GCLK_ADC1 must be used to configure the clock for AC as GCLK_AC is not 

  * functional. Errata reference: 13404 

  */

system_gclk_chan_set_config(34, &gclk_chan_conf);

system_gclk_chan_enable(34);

system_gclk_chan_set_config(AC_GCLK_ID, &gclk_chan_conf);

system_gclk_chan_enable(AC_GCLK_ID);

#endif

 

system_gclk_chan_set_config(AC_GCLK_ID, &gclk_chan_conf);

system_gclk_chan_enable(AC_GCLK_ID);

 

 

Why? Revision B had a bug per Errata 13404 where the GCLK was mapped wrong to ADC1.

 

However this was fixed in later revisions...but ASF was never updated. So the proper gclk never gets turned on and you get stuck in sync.

Last Edited: Thu. Oct 12, 2017 - 07:15 PM