MCU User Forum
  OSCICN|=0x20 does not work for 411

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   OSCICN|=0x20 does not work for 411
aaa1982
Member
posted August 10, 2010 10:20 AM     Click Here to See the Profile for aaa1982   Click Here to Email aaa1982     Edit/Delete Message
Hi:
The program can not enter supsend mode by OSCICN|=0x20;

The structure of the program is like below;
main()
{
_CLOSE_WDT;
//RTC_Init();
while(1)
{
OSCICN=0x20;
}

}

I found that if the RTC peripheral is not initilized or the RTC interrupt is not enabled,the OSCICN|=0x20 dose not work.

(I determine whether the supsed mode is enter by the current consumption)

I know the RTC can wake up mcu from suspend mode,but if it has any relationship about the effect of suspend mode?

aaa1982


[This message has been edited by aaa1982 (edited August 10, 2010).]

IP: Logged

Scotty
Member
posted August 10, 2010 10:41 AM     Click Here to See the Profile for Scotty     Edit/Delete Message
Hi aaa1982,

I found that if the RTC peripheral is not initilized or the RTC interrupt is not enabled,the OSCICN|=0x20 does not work.
...
I know the RTC can wake up mcu from suspend mode,but if it has any relationship about the effect of suspend mode?

The datasheet says that the reset value of RTC0CN register is variable on reset. So I could imagine that the MCLKEN flag is (sometimes) set on reset. Where MCLKEN itself has no effect on the core, the OSCFAIL flag might be also set, and the datasheet says:

When the smaRTClock Missing Clock Detector is enabled, OSCFAIL (RTC0CN.5) is set by hardware if RTCCLK remains high or low for more than 50 µs.
A smaRTClock Missing Clock detector timeout
triggers three events:
1.Awakening the internal oscillator from Suspend Mode.
2.smaRTClock Interrupt (If the smaRTClock Interrupt is enabled).
3.MCU reset (If smaRTClock is enabled as a reset source).
Note: The smaRTClock Missing Clock Detector should be disabled when making changes to the oscillator
settings in RTC0XCN.

Regards,

Scotty

IP: Logged

aaa1982
Member
posted August 10, 2010 07:12 PM     Click Here to See the Profile for aaa1982   Click Here to Email aaa1982     Edit/Delete Message
Hi Scotty:

If I initilized the RTC(settings in RTC0XCN correctly) But donot enable the RTC interrupt, it also does not work.

I remember I once use 410 and it could enter suspend mode only by OSCICN|=0x20,nothing extra operation is required.

For smaller size, I change to 411 and use the suspend+RTC wakeup mode which silabs provided in his example F41x_RTC_Suspend.c. It also work correctly.
But yesterday, I want to use the supsend mode without the disturb of RTC(Measure the current consumption in suspend mode)and find it can not wokr.
Is there any other question can cause this problem?


IP: Logged

aaa1982
Member
posted August 11, 2010 01:52 AM     Click Here to See the Profile for aaa1982   Click Here to Email aaa1982     Edit/Delete Message
The real code is as below


#include "oscillator.h"
#include"rtc.h"
static aaa=0;
static bbb=0;
void RTC_Init (void)
{
unsigned char i;

RTC0KEY = 0xA5; // unlock the RTC interface
RTC0KEY = 0xF1;

RTC_Write (RTC0CN, 0x80); // enable RTC

RTC_ClearCapture(); // clear CAPTUREn registers
RTC_ClearAlarm (); // clear ALARMn registers

RTC_SetBits (RTC0XCN, 0x40); // set crystal mode
// RTC_ClearBits (RTC0XCN, 0xE0); //clr ACG and set self oscillate 20Khz mode
OSCICN = 0x80; // switch to 192 kHz int osc
for (i=0xFF;i!=0;i--); // wait > 1 ms
OSCICN = 0x87; // switch back to 24.5 MHz int osc

// wait for clock valid
// while ((RTC_Read (RTC0XCN) & 0x10)== 0x00);

RTC_SetBits (RTC0CN, 0x40); // enable missing clock detector
RTC_SetBits (RTC0XCN, 0x80); // enable ACG to save current

RTC_SetBits (RTC0CN, 0x02); // transfer capture to clock
RTC_SetBits (RTC0CN, 0x10); // enable RTC run
RTC_SetBits (RTC0CN, 0x08); // enable RTC alarm
EIE1 |= 0x02; // enable RTC interrupt
}


void Timer2_Wait_Ms(uchar ms)
{
uchar i;
TMR2CN&=~0xFC; //clear TF2H,TF2L,TF2LEN,T2SPLIT and TR2,
//define timer2 as 16 bit auto_load mode
//disable low byte interrupt
//timer2 split mode disable
CKCON|=0x10; //set T2ML, choose sysclk as timebase of timer2
TMR2RLH=(-(SYSCLK/1000))>>8;
TMR2RLL=-(SYSCLK/1000);
TMR2H=(-(SYSCLK/1000))>>8;
TMR2L=-(SYSCLK/1000);
TMR2CN|=0x04; //start timer2
for(i=0;i {
while((TMR2CN&0x80)!=0x80);
TMR2CN=(TMR2CN&0x7F);
}

TMR2CN&=~0x04;
}
void main (void)
{
PCA0MD &= ~0x40; // disable watchdog timer
PCA0MD=0x00;

OSCICN = 0x87;
RTC_Init (); // initiralize RTC
// EA = 1; // set global interrupt enable

while (1)
{
OSCICN |= 0x20;
}
}


IP: Logged

aaa1982
Member
posted August 13, 2010 09:41 AM     Click Here to See the Profile for aaa1982   Click Here to Email aaa1982     Edit/Delete Message
Is there anyone may give me some advise?

OSCICN|=0x20 still not work.

I have already spent four days to try to fix the problem but it still there.

Is there any official ways to inform this problem in china?

I was afraid of using 410 or 411 in my new project now

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | MCU User Forum

Have you seen our MCU Knowledge Base?


Ultimate Bulletin Board 5.47b