Hi, I used the STOP3 and RTC interrupt to realize sensor sampling with very low power consumption. However, the minimum supply current with a battery of 3V is 5mA, which is much larger than that of the datasheet (450nA at STOP3 mode). I don't know why. Is there any code example to illustrate how to sleep and work with very low power?
Looking forwards your reply.
Best,
Fantasticxp
Is there body can help me? Looking forwards to the technical support.
Hello,
In addition to Tom's advice, here are a couple of things to check:
When you measure the current draw, the BDM Multilink tool should be disconnected.
Regards,
Mac
Hi, Tom and Mac,
Thanks you very much. I looked up in the forum and did what others have been told. All the pin, including the unshown pin, have been set output low. The SOPT1_BKGDPE has been set to be 0. The SPMSC1_LVDE and SPMSC1_LVDSE both have been set to be 0. When I measure, the BDM Multilink is disconnectted. It seems to be better, but the supply current still has 2.6mA. How about the clock setting? Following is my code. I appreciate for your help.
With regards.
Thanks a lot.
void main(void)
{
MCU_Init(); /* Function that initializes the MCU */
GPIO_Init(); /* Function that initializes the Ports of the MCU */
ADC_Init(); /* Function that initializes the ADC*/
APCTL2_ADPC15 = 1; /* Select the channel for ADC input (the pin stop working as GPIO) */
APCTL3_ADPC16 = 1; /* Select the channel for ADC input (the pin stop working as GPIO) */
APCTL3_ADPC17 = 1; /* Select the channel for ADC input (the pin stop working as GPIO) */
APCTL1_ADPC1 = 1; /* Select the channel for ADC input (the pin stop working as GPIO) */
SCIOpenCommunication();// Opens SCI communication
EnableInterrupts; /* enable interrupts */
RTC_Init(); /* Function that initializes the RTC*/
for(;
{
SOPT1_STOPE=1;
_Stop;
}
}
void MCU_Init(void) {
SOPT1 = 0x21; /* Watchdog disable. Stop Mode Enable. Background Pin Disable. RESET pin enable */
SCGC1 = 0x11; /* Bus Clock to ADC,SCI1 is enable */
SCGC2 = 0x04; /* Bus clock to the RTC module is enable*/
SPMSC1_LVDE = 0;
SPMSC1_LVDRE = 1;
SPMSC1_LVDSE=0;
if(NVICSTRM != 0xFF) // Set Clock 24 Mhz
ICSTRM=NVICSTRM;
else
ICSTRM=0xBC;
ICSC1 = ICSC1_IREFS_MASK | ICSC1_IRCLKEN_MASK;
ICSC2=0x00;
ICSSC = ICSSC_FTRIM_MASK;
while(ICSC1_CLKS!=ICSSC_CLKST);
}
void GPIO_Init(void) {
//Setting IO low output
PTADD=0xFF;
PTAD= 0x00;
PTBDD=0xFF;
PTBD= 0x00;
PTCDD=0xFF;
PTCD= 0x00;
PTDDD=0xFF;
PTDD= 0x00;
PTEDD=0xFF;
PTED= 0x00;
PTFDD=0xFF;
PTFD= 0x00;
PTGDD=0xFF;
PTGD= 0x00;
PTHDD=0xFF;
PTHD= 0x00;
//Setting of the pin which are used
PTADD_PTADD0 = 1;
PTAD_PTAD0 = 1;
PTDDD_PTDDD6 = 1;
PTDD_PTDD6 = 1;
PTDDD_PTDDD7 = 1;
PTDD_PTDD7 = 1;
PTEDD_PTEDD5 = 1;
PTED_PTED5 = 1;
PTADD_PTADD2 = 1;
PTAD_PTAD2 = 1;
PTCDD_PTCDD5 = 1;
PTCD_PTCD5 = 0;
PTDDD_PTDDD5 = 1;
PTDD_PTDD5 = 0;
PTCDD_PTCDD0 = 0;
PTCDD_PTCDD1 = 0;
PTBDD_PTBDD1 = 1;
PTBDD_PTBDD0 = 0;
}
void ADC_Init(void)
{
// Configures ADC peripheral (ADC clock = 8MHz)
// Selects ADC continuous conversion
ADCCFG = 0x98; /* Input clock/1. Low power, Long Sample time configuration. 10-bit conversion */
ADCSC2 = 0x00; /* Software trigger selected */
ADCSC1_ADCO = 0;
}
void SCIOpenCommunication(void)
{
if (!sci_status)
{
// Open SCI Communications
sci_status = TRUE;
// Set Baud Rate Modulo Divisor
SCI1BD = BR;
// Normal operation, 8 data bits stop and no Parity
SCI1C1 = 0x00;
// Trasmitter and Receiver Enable
//SCI1C2 = SCI1C2_RIE_MASK |SCI1C2_TE_MASK |SCI1C2_RE_MASK;
SCI1C2 = 0x0C;
SCI1C3 = 0x00;
}
}
void RTC_Init(void)
{
RTCSC=0x18;
RTCMOD=0x23;
}
Hello,
It always helps to say what is the intended operation of your code - it is not immediately obvious. You appear to have enabled interrupts for the RTC, and I assume this is your wakeup source, but you have not shown the ISR code. If you are not properly clearing the interrupt flag, it is possible that you do not ever enter stop 3 mode.
For "write once" registers, all bits need to be simultaneously written, rather than a single bit at a time. With the code -
for ( ; ; ) {
SOPT1_STOPE = 1;
_Stop;
}
the highlighted statement achieves absolutely nothing, since it refers to a write once bit (I assume that the STOP instruction is already enabled within your initialisation function). This code would also imply that all the "work" following a wakeup would occur within the ISR that initiates the wakeup.
One method to determine for how long the MCU operates in stop mode would be to set a GPIO bit prior to the stop instruction, and to clear the bit following the stop instruction. The result can then be observed with an oscilloscope. Actually, this would also include the ISR execution time, which should be a very short period relative to the timer period.
If your intent is to complete an ADC conversion whilst in stop 3, this will not work with your present setup, using the bus clock for the ADC module. I do not see where you are initiating an ADC conversion, except once at the completion of the initialisation, and the pins for ADC operation have not been enabled at this point. Why is this part of the initialisation process not within the initialisation function?
Regards,
Mac
Hello,
Anyone interested in looking at low power mode for 9S08QE8 written in assembly is invited to check out my project
http://www.rasmicro.com/Low_Power_Temp_Sensor.htm
Roger
This question has been answered a number of times before. In the Forum search box at the upper right of this web page, enter STOP3 and click on Search. A number of forum threads on the subject will be displayed. Hopefully you will find your answer in one of those.
---Tom