Forum: Mikrocontroller und Digitale Elektronik AVR32_PM.unlock funktioniert nicht


von Karl (Gast)


Lesenswert?

Hallo,

ich versuche gerade einen AT32UC3C auf externen Oszillator umzustellen.
Irgendwie kann ich aber nicht auf die dafür notwendigen "gelockten" 
Power Manger(PM)-Register zugreifen. Ich habe es mit folgendem Code 
probiert:
1
AVR32_PM.unlock = 0xAA000000 | AVR32_PM_MCCTRL;
2
AVR32_PM.MCCTRL.mcsel = 1;

Leider funktioniert das so nicht und ich bekomme damit immer einen 
Access Error (AE)-Interrupt, d.h. das "unlocken" funktioniert wohl 
irgendwie nicht.

Beim Zugriff auf die SCIF-Register klappt es aber:
1
AVR32_SCIF.unlock = 0xAA000000 | AVR32_SCIF_OSCCTRL;  
2
AVR32_SCIF.oscctrl[0] = 0x00010040;
3
while ( !(AVR32_SCIF.pclksr & 0x1) ); //Wait till oscillator is stable and ready to be used as clock source.

Hat jemand eine Idee, woran das liegen könnte??? Bin schon total 
verzweifelt :(

Viele Grüße
Karl

von Michael B. (Gast)


Lesenswert?

Hi Karl,

mit folgendem Code sollte alles sofort funktionieren:

AVR32_SCIF.unlock = 0xAA000000 | AVR32_SCIF_OSCCTRL;
AVR32_SCIF.oscctrl[0] = 0x00010040;
while ( !(AVR32_SCIF.pclksr & 0x1) ); // Wait for stable crystal

// AVR32_ENTER_CRITICAL_REGION( ); // --> Import ASF-Modul "intc"
AVR32_PM.unlock = 0xAA000000 | AVR32_PM_MCCTRL;
//PM_UNLOCK(AVR32_PM_MCCTRL); // --> Import ASF "PM-Modul"
//AVR32_PM.mcctrl = AVR32_PM_MCCTRL_MCSEL_OSC0; // --> Works
AVR32_PM.mcctrl = 1; // Works also
// AVR32_LEAVE_CRITICAL_REGION( ); // --> Import ASF-Modul "intc"

while(1)
{
// Do something nice SEB ;-)
}

VG,
Michael

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.