CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

pic24fj128ga310 + CCS 5.051 = DEEP SLEEP mode not working!
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ipq



Joined: 20 Aug 2015
Posts: 17

View user's profile Send private message

pic24fj128ga310 + CCS 5.051 = DEEP SLEEP mode not working!
PostPosted: Fri Aug 26, 2016 8:35 am     Reply with quote

Hello,

I know this is a very frequent question but I tried to solve it by searching on the forum and I failed...

This is my source code:

main.h
Code:

#include <24FJ128GA310.h>
#device ICSP=1
#use delay(internal=8000000)

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES LVR                      //Low Voltage Regulator Enabled, Controlled in Software
#FUSES PROTECT                  //Code protected from reads
#FUSES NOJTAG                   //JTAG disabled
//#FUSES NOCKSNOFSM               //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES WPCFG                    //Configuration Words page is erase/write-protected
#FUSES NODSWDT                  //Deep Sleep Watchdog Timer disabled

main.c
Code:

#include <main.h>

void main()
{
   //Example blinking LED program
   while(true)
   {
   
   setup_adc_ports(NO_ANALOGS);
   setup_vref(VREF_DISABLED);
   
      output_a(0);
      output_b(0);
      output_c(0);
      output_d(0);
      output_e(0);
      output_f(0);
      output_g(0);
     
      //output_high(PIN_D4 | PIN_D5);
      output_high(PIN_D4);
      output_high(PIN_D5);
     
      output_high(PIN_F6);
      output_high(PIN_G2);
     
      output_low(PIN_D11);
       output_low(PIN_E4);
     
      output_low(PIN_D0);
      output_low(PIN_D1);
      output_low(PIN_D2);
      output_low(PIN_D3);
           
      disable_interrupts(INTR_GLOBAL);
     
      sleep(SLEEP_FULL);
   }

}

I'm running this source code is a very simple board with the mcu a couple of leds and a buzzer.

It is strange but I cannot decrease the consumption under 9mA.

The content of the *.lst
Code:

00000:  GOTO    200
.................... #include <main.h>
.................... #include <24FJ128GA310.h>
.................... //////////// Standard Header file for the PIC24FJ128GA310 device ////////////////
.................... ///////////////////////////////////////////////////////////////////////////
.................... ////        (C) Copyright 1996, 2014 Custom Computer Services          ////
.................... //// This source code may only be used by licensed users of the CCS C  ////
.................... //// compiler.  This source code may only be distributed to other      ////
.................... //// licensed users of the CCS C compiler.  No other use, reproduction ////
.................... //// or distribution is permitted without written permission.          ////
.................... //// Derivative programs created using this software in object code    ////
.................... //// form are not restricted in any way.                               ////
.................... ///////////////////////////////////////////////////////////////////////////
.................... #device PIC24FJ128GA310
.................... 
.................... #list
.................... 
.................... #device ICSP=1
.................... #use delay(internal=8000000)
.................... 
.................... #FUSES NOWDT                    //No Watch Dog Timer
.................... #FUSES LVR                      //Low Voltage Regulator Enabled, Controlled in Software
.................... #FUSES PROTECT                  //Code protected from reads
.................... #FUSES NOJTAG                   //JTAG disabled
.................... //#FUSES NOCKSNOFSM               //Clock Switching is disabled, fail Safe clock monitor is disabled
.................... #FUSES WPCFG                    //Configuration Words page is erase/write-protected
.................... #FUSES NODSWDT                  //Deep Sleep Watchdog Timer disabled
.................... 
.................... 
.................... 
.................... #define LED PIN_E9
.................... #define DELAY 250
.................... 
.................... //#bit DSEN = DSCONH.7
.................... 
.................... 
.................... 
.................... void main()
*
00200:  MOV     #2780,W15
00202:  MOV     #27FF,W0
00204:  MOV     W0,20
00206:  NOP     
00208:  BSET.B  81.7
0020A:  MOV     #0,W0
0020C:  MOV     W0,384
0020E:  MOV     #FFFF,W0
00210:  MOV     W0,386
00212:  CLR     744
00214:  MOV.B   #5,W0L
00216:  MOV.B   W0L,588
00218:  CLR     4E0
0021A:  CLR     4E2
0021C:  CLR     4E4
0021E:  CLR     4E6
00220:  CLR     4E8
00222:  CLR     4EC
.................... {
.................... 
....................    //Example blinking LED program
....................    while(true)
....................    {
....................     
....................    setup_adc_ports(NO_ANALOGS);
00224:  CLR     4E0
00226:  CLR     4E2
00228:  CLR     4E4
0022A:  CLR     4E6
0022C:  CLR     4E8
0022E:  CLR     4EA
00230:  CLR     4EC
00232:  MOV     #0,W0
....................    setup_vref(VREF_DISABLED);
00234:  CLR     632
....................     
....................       output_a(0);
00236:  CLR     2C0
00238:  CLR     2C4
....................       output_b(0);
0023A:  CLR     2C8
0023C:  CLR     2CC
....................       output_c(0);
0023E:  CLR     2D0
00240:  CLR     2D4
....................       output_d(0);
00242:  CLR     2D8
00244:  CLR     2DC
....................       output_e(0);
00246:  CLR     2E0
00248:  CLR     2E4
....................       output_f(0);
0024A:  CLR     2E8
0024C:  CLR     2EC
....................       output_g(0);
0024E:  CLR     2F0
00250:  CLR     2F4
....................       
....................       //output_high(PIN_D4 | PIN_D5);
....................       output_high(PIN_D4);
00252:  BCLR.B  2D8.4
00254:  BSET.B  2DC.4
....................       output_high(PIN_D5);
00256:  BCLR.B  2D8.5
00258:  BSET.B  2DC.5
....................       
....................       output_high(PIN_F6);
0025A:  BCLR.B  2E8.6
0025C:  BSET.B  2EC.6
....................       output_high(PIN_G2);
0025E:  BCLR.B  2F0.2
00260:  BSET.B  2F4.2
....................       
....................       output_low(PIN_D11);
00262:  BCLR.B  2D9.3
00264:  BCLR.B  2DD.3
....................        output_low(PIN_E4);
00266:  BCLR.B  2E0.4
00268:  BCLR.B  2E4.4
....................       
....................       output_low(PIN_D0);
0026A:  BCLR.B  2D8.0
0026C:  BCLR.B  2DC.0
....................       output_low(PIN_D1);
0026E:  BCLR.B  2D8.1
00270:  BCLR.B  2DC.1
....................       output_low(PIN_D2);
00272:  BCLR.B  2D8.2
00274:  BCLR.B  2DC.2
....................       output_low(PIN_D3);
00276:  BCLR.B  2D8.3
00278:  BCLR.B  2DC.3
....................       
....................             
....................       disable_interrupts(INTR_GLOBAL);
0027A:  BCLR.B  81.7
0027C:  MOV     #E0,W4
0027E:  MOV     W4,42
00280:  BSET.B  81.7
....................       
....................       sleep(SLEEP_FULL);
00282:  PWRSAV  #0
00284:  GOTO    224
....................    }
.................... 
.................... }
00288:  PWRSAV  #0

Configuration Fuses:
Code:

   Word  1L: 1B9F   WPOSTS16 WDT128 NOWDT WINDIS ICSP1 LVR NODEBUG NOWRT PROTECT NOJTAG
          H: 0000 
   Word  2L: FFFF   NOPR IOL1WAY NOOSCIO FRC_PS VREFNORM_CVREFNORM IESO
          H: 0000 
   Word  3L: BEFF   WPFP VBATBOR SOSC_DIG WDTWIN_25% BROWNOUT WPDIS WPCFG WPEND
          H: 0000 
   Word  4L: FF7F   DSWDTCK_LPRC DSBOR NODSWDT DS_SW
          H: 0000

Any word of wisdom???

Thank you in advance!!! Confused
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 26, 2016 9:56 am     Reply with quote

Post your schematic.


How to post an image on the CCS forum:
Go to this website: http://postimage.org/
Upload your image. Select family safe. Then click the first button for
"Hotlink to Forum" to get a link to the image.
Then go to the CCS forum and type Ctrl-V to paste the link into a post.

If postimage.org doesn't work in your country, then use Google to find
another free image hosting site for forums.
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Fri Aug 26, 2016 1:18 pm     Reply with quote

One suggestion. Try setting Port C.14 as an input.

Not sure what the default SOSC configuration is, and you are not explicitly setting this in the fuses. Wondering about Note 2 on table 29-3.
ipq



Joined: 20 Aug 2015
Posts: 17

View user's profile Send private message

Schematic
PostPosted: Mon Aug 29, 2016 3:25 am     Reply with quote

Hello,

See schematic on: http://tinyurl.com/deepsleep-pic24

This is the complete schematic of the pcb in which we want to decrease the consumption.
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Aug 29, 2016 7:07 am     Reply with quote

just a couple of comments from a 'dinosaur'..

1) the schematic would be a lot easier to read if all +5V terminations were 'pointing up' and all grounds were pointing 'down'. yeah I'm old but was taught that way. Same holds true for the 32KHz xtal layout

2) the Vbat PIC pin goes to 3volts, seems to be fed from the regulator. if so why bother with deep sleep as it appears the PIC is 'line' powered.

3) looks like that PIC has onboard USB, so be sure you can configure those D+, D- pins for alternate use. Some PICs can't.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Mon Aug 29, 2016 7:23 am     Reply with quote

Look at figure 2-2 in the data sheet.

Read this paragraph:

"During programming and debugging, the resistance
and capacitance that can be added to the pin must
be considered. Device programmers and debuggers
drive the MCLR pin. Consequently, specific voltage
levels (VIH and VIL) and fast signal transitions must
not be adversely affected. Therefore, specific values
of R1 and C1 will need to be adjusted based on the
application and PCB requirements. For example, it is
recommended that the capacitor, C1, be isolated
from the MCLR pin during programming and
debugging operations by using a jumper (Figure 2-2).
The jumper is replaced for normal run-time
operations."

Leaving the 0.1uF on MCLR when trying to use the ICD, is a recipe for it to not be reliable.....

Are you sure your capacitor on the Vcap pins meets the ESR requirements?.
Is it as close as required to the pin?. Section 2.4 in the data sheet.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 29, 2016 8:22 am     Reply with quote

Where are you measuring the current ? At the board's input power
terminals ? If so, you have a LD1117S33TR regulator as U1. This
regulator has a quiescent current of 5 to 10 ma. That's probably
your whole problem. See Table 6. Electrical characteristics of LD1117#33
on page 12 of the data sheet:
http://www.st.com/resource/en/datasheet/ld1117.pdf
Code:
Id  Quiescent current   Vin ≤ 15V   5 to 10 mA
ipq



Joined: 20 Aug 2015
Posts: 17

View user's profile Send private message

PostPosted: Mon Aug 29, 2016 8:24 am     Reply with quote

temtronic wrote:
just a couple of comments from a 'dinosaur'..

1) the schematic would be a lot easier to read if all +5V terminations were 'pointing up' and all grounds were pointing 'down'. yeah I'm old but was taught that way. Same holds true for the 32KHz xtal layout

2) the Vbat PIC pin goes to 3volts, seems to be fed from the regulator. if so why bother with deep sleep as it appears the PIC is 'line' powered.

3) looks like that PIC has onboard USB, so be sure you can configure those D+, D- pins for alternate use. Some PICs can't.

Jay



Hello,

Thank you for your feedback. It is appreciated. The reason why I am not using arrows pointing up is because in Altium it is faster to use standard symbols. However, I'll take your suggestion into account:)

The device is batt powered, so vbat has no effect here.

Regarding the USB, this MCU does not have this peripheral.

Thank you for your appreciated help
ipq



Joined: 20 Aug 2015
Posts: 17

View user's profile Send private message

PostPosted: Mon Aug 29, 2016 8:27 am     Reply with quote

Ttelmah wrote:
Look at figure 2-2 in the data sheet.

Read this paragraph:

"During programming and debugging, the resistance
and capacitance that can be added to the pin must
be considered. Device programmers and debuggers
drive the MCLR pin. Consequently, specific voltage
levels (VIH and VIL) and fast signal transitions must
not be adversely affected. Therefore, specific values
of R1 and C1 will need to be adjusted based on the
application and PCB requirements. For example, it is
recommended that the capacitor, C1, be isolated
from the MCLR pin during programming and
debugging operations by using a jumper (Figure 2-2).
The jumper is replaced for normal run-time
operations."

Leaving the 0.1uF on MCLR when trying to use the ICD, is a recipe for it to not be reliable.....

Are you sure your capacitor on the Vcap pins meets the ESR requirements?.
Is it as close as required to the pin?. Section 2.4 in the data sheet.


Yes, all components are placed according datasheet and the capacitor is like suggested (ESR is OK).

The reason why I did not place the jumper in the MCLR line is because I never faced any problem during programming, so I decided not to put it...

However I'll take your words into account for future modifications.

Thanks!
ipq



Joined: 20 Aug 2015
Posts: 17

View user's profile Send private message

PostPosted: Mon Aug 29, 2016 8:36 am     Reply with quote

PCM programmer wrote:
Where are you measuring the current ? At the board's input power
terminals ? If so, you have a LD1117S33TR regulator as U1. This
regulator has a quiescent current of 5 to 10 ma. That's probably
your whole problem. See Table 6. Electrical characteristics of LD1117#33
on page 12 of the data sheet:
http://www.st.com/resource/en/datasheet/ld1117.pdf
Code:
Id  Quiescent current   Vin ≤ 15V   5 to 10 mA


That was my first conclusion but then I removed the regulator, powered the board directly at 3.0 volts and the consumption still remains above the 3mA

I know it is complicated decrease the consumption and make it lower tha 1mA, but I've tried removing all components on the PCB and it is already higher than 3mA...

Strange thing...

Any idea?
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Mon Aug 29, 2016 9:23 am     Reply with quote

The MCLR rise time requirements for ICD, are many times lower than those for programming. When doing normal programming it can take mSec to reach the Vpp. Using the ICD is has to get to the same level in a few uSec.
This is why the ICD 'sheet' from Microchip (this is the one for ICD3, but the same applies to all the ICD units):
<http://ww1.microchip.com/downloads/en/DeviceDoc/DS-51765C.pdf>
has as it's second warning down in the 'additional precautions' box 'do not use capacitors on MCLR'.

Your power is 'odd'. I was thinking of things possibly oscillating (the regulator can do this).

Are you sure you are turning off the LCD peripheral fully?.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 29, 2016 9:54 am     Reply with quote

Quote:

That was my first conclusion but then I removed the regulator, powered
the board directly at 3.0 volts and the consumption still remains above the 3mA

That's a 1K load, or maybe three 3.3K loads. What do you have plugged
into the various connectors, RFCONN, Keypad, and IOS ?
jgschmidt



Joined: 03 Dec 2008
Posts: 184
Location: Gresham, OR USA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Aug 29, 2016 2:06 pm     Reply with quote

In my explorations for achieving the lowest power possible sleep modes I've found the following doc from Microchip helpful:

http://ww1.microchip.com/downloads/en/AppNotes/01416a.pdf
_________________
Jürgen
www.jgscraft.com
ipq



Joined: 20 Aug 2015
Posts: 17

View user's profile Send private message

PostPosted: Tue Aug 30, 2016 12:40 am     Reply with quote

PCM programmer wrote:
Quote:

That was my first conclusion but then I removed the regulator, powered
the board directly at 3.0 volts and the consumption still remains above the 3mA

That's a 1K load, or maybe three 3.3K loads. What do you have plugged
into the various connectors, RFCONN, Keypad, and IOS ?


There is nothing. Those IOs right now are connected to different connectors to expand system capabilities.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 30, 2016 12:43 am     Reply with quote

What instrument are you using to measure the current ? Have you
checked the instrument with, say 3v running through a 1 MegOhm resistor ?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group