UC3C: AST initialization problem

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

Hi all, back again with my problems with AT32UC3C0512C! 

 

The issue: AST initialization jams because CLKBUSY signal never goes down:

    AVR32_AST.CLOCK.cssel = AST_OSC_32KHZ;
    
    while (AVR32_AST.SR.clkbusy)
        ;
    
    AVR32_AST.CLOCK.cen = 1;
    
    while (AVR32_AST.SR.clkbusy)
        ;

That's the procedure as described in the manual http://www.atmel.com/images/doc3... on page 136.

 

The AST status register SR reads ‭0001 0001 0000 0000 0000 0000 0000 0000‬ (before and after setting cssel), meaning that:

CLKREADY = 0

CLKBUSY = 1

READY = 0

BUSY = 1

 

Worrying thing is that AST_EXAMPLE11 doesn't work either -- it fails to the same thing.

 

There's a similar issue http://www.avrfreaks.net/forum/u... but the solution presented there didn't help me, unfortunately.

 

Any ideas?

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

Hi Jack,

 

OSCCTRL32 configured? (SCIF)

Is there an external clock source or a crystal connected to XIN32/XOUT32 pin(s)?

 

First try to set RCSYS as clock source.

 

BR,

M

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

Thanks for ideas Menahem!

 

I'm trying it on the UC3C-EK dev board so there is a 32 kHz RTC crystal on-board. Atmel's example was actually supposed to work on this out-of-the-box, but it didn't.

 

Anyway I tried switching AST_OSC_32KHZ to AST_OSC_RC, but the CLKBUSY still stays high. Actually I'm not sure if trying to change it has any effect, because CLKBUSY must be 0 so that "The clock is ready and can be changed." (manual p. 145)

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

Sorry, I misread the "(before and after setting cssel)" line.

Can you debug the software from the very beginning? Maybe the example code writes the register incorrectly somewhere earlier...

 

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

Is the AST enabled ? (SR.EN = 1)

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

Some progress on this.

 

It seems that neither reset nor re-flashing clears CLKBUSY signal. So if something goes wrong in the AST initialization, I need to unplug power entirely in order to try again.

 

After figuring that out, I got it working using the RCSYS oscillator (thanks Menahem!).

 

However, the initialization of the external crystal is not working. Atmel's example just disregards the return value (status) of scif_start_osc32(), so I didn't notice it failing. Here's the procedure without any exit-on-timeout, so it just hangs at the last while().

// Unlock OSCCTRL32 register
AVR32_SCIF.UNLOCK.addr = 0x4C;
AVR32_SCIF.UNLOCK.key = 0xAA;
for (unsigned int i = 0; i < 10000; i++)
    ;

AVR32_SCIF.OSCCTRL32.mode = 1;            // 2-pin crystal mode
AVR32_SCIF.OSCCTRL32.startup = 6;         // 262144 cycles to wait for the crystal start-up
AVR32_SCIF.OSCCTRL32.osc32en = 1;         // enable = yes
while (AVR32_SCIF.PCLKSR.osc32rdy == 0)   // OSC32RDY signal should go high in a second or two
    ;

 

Looking at the board, I'm pretty sure the crystal is there and connected to the right pins of the MCU. Maybe it just needs some additional initialization which I'm unaware of.

 

I'll run an over-the-weekend test with the RCSYS to see how much it drifts. Maybe it's good enough.

 

I also have a custom board with AT32UC3C1512C (the same chip as 0512C but different packaging) and a crystal on it, which I can try later.

 

mikech wrote:
Is the AST enabled ? (SR.EN = 1)

Enabling must be preceded by the initialization steps that I showed in the first post.

Last Edited: Fri. Apr 28, 2017 - 04:16 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

After the unlock you must write the new register value in the very next PB access.

E.g.:

AVR32_SCIF.UNLOCK = 0xAA00004CU;

AVR32_SCIF.OSCCTRL32 = (mode << MOD_OFFS) | (startup << STARTUP_OFFS) | ...;