I have a problem with getting 32 kHz oscillator to run. I suppose that either XOSC or RCOSC should run automatically after reset. However, SLEEPSTA.CLK32K stays low indefinitely. What is even more weird is that CLKCONSTA is always zero even if I write something to CLKCONCMD register.
So it seems that I've missed some initialize step somewhere but I cannot understand what. This code has been working earlier (it is part of a bigger project) so I don't understand why it's not working any more. Could there be some hardware issue (not probable since same HW is used in another project and it's working)? I have a CC debugger with IAR and I can verify that code is working except that 32 kHz clock is not running and therefore timers are not working. Any help would be greatly appreciated!
Here is a code snippet of affected code part:
CLKCONCMD = 0x98; // 32kHz RCOSC : 32MHz XOSC : Tick 4MHz : System 32 MHz // Enable Interrupts and receiver; P0IE = 1; // Enable Interrupts from Port 0 IEN2 |= 0x10; // Enable Interrupts from Port 1 IEN2 |= 0x02; // Enable Interrupts from Port 2 __enable_interrupt(); if(SleepState > kSleepIdle) { // wait for 32MHz clock to stabilize while((CLKCONSTA & 0x40)) { // I have noticed that CLKCONSTA is always zero ; } // wait for positive transition on 32kHz clock (CLK32K bit) - Sleep timer register has been updated while((SLEEPSTA & 0x01)) { // Wait for a low or already in a low ; } while(!(SLEEPSTA & 0x01)) { // Wait for a high. Code never continues from here, because clock stays low! ; } Timer2SyncStart(); // Restart Timer2 }