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

problem in sleep mode function in ccs compiler
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
deepakkspdprs



Joined: 09 Mar 2017
Posts: 6

View user's profile Send private message Send e-mail

problem in sleep mode function in ccs compiler
PostPosted: Thu Mar 09, 2017 5:57 am     Reply with quote

Am facing problem in sleep mode function.

This My Code:
Code:

main()
{
 InitPorts();
 Mdm_Init();
 
while(1)
  {
   LED = 0x01;
   delay_ms(1000);
   LED = 0x01;
   sleep(); // ---> I have no error comes from this function during compile.
   sleep(SLEEP_FULL); // ---> But i have one error comes from this function during compile. The error is "Expecting a close paren".
   sleep(SLEEP_IDLE); // -->Above mention error comes from this function also.
  }
}


My CCS Compiler version is V4.129 & MPLAB IDE version is V8.83.
Pls give solution for this problem asap...
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Thu Mar 09, 2017 6:08 am     Reply with quote

Always state the PIC you are using.
Also How do you know it is not working?
deepakkspdprs



Joined: 09 Mar 2017
Posts: 6

View user's profile Send private message Send e-mail

Problem in sleep mode function in ccs compiler
PostPosted: Thu Mar 09, 2017 6:37 am     Reply with quote

Am using PIC 18f67k90 controller.

Error come from during MPLAB compiler. If am using sleep() it's working fine but current consumption near to 10mA.
So i need go for deep sleep mode because of low power consumption then am go for sleep(SLEEP_FULL) but it's not working, it's show error. Is "Expecting a close paren" in MPLAB compiler.
deepakkspdprs



Joined: 09 Mar 2017
Posts: 6

View user's profile Send private message Send e-mail

PostPosted: Fri Mar 10, 2017 11:33 pm     Reply with quote

Pls any give me solution. It's urgent. Is there any problem for ccs compiler or MPLAB IDE ?
deepakkspdprs



Joined: 09 Mar 2017
Posts: 6

View user's profile Send private message Send e-mail

PostPosted: Fri Mar 10, 2017 11:35 pm     Reply with quote

pls ignore previous mail.

Pls anyone give me solution. Is there any problem for ccs compiler or MPLAB IDE...its urgent..
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Mar 11, 2017 1:20 am     Reply with quote

Some ideas:
1) Are you sure (SLEEP_FULL) is valid for your compiler version?
(check the header file)

2) High current consumption during sleep is typically caused by
pull-up resistors, inputs or outputs set incorrectly or peripherals
not turned off.

Do a search for the words current draw sleep and search for all
terms. You will find a lot of previous posts on this topic if you do
some reading.
_________________
Google and Forum Search are some of your best tools!!!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sat Mar 11, 2017 2:56 am     Reply with quote

Lots of confusing things here. You talk about 'MPLAB compiler'. If you are using the MPLAB compiler, then 'wrong forum'. However you sound to actually be using the CCS compiler, in the MPLAB IDE (not the MPLAB compiler).

Now if you look at the manual for 'sleep', it says:
Quote:

mode - for most chips this is not used. Check the device header for special options on some chips.


Options that will work fine on one chip, will not work on others. This is what Dyeatman is asking.
Sleep on your chip by default _is_ SLEEP_FULL all the time.
You can put it into a higher power 'sleep' mode, by setting the IDLE bit, but this will draw more power, not less. This is done by selecting the oscillator you want to use during sleep (using setup_oscillator), and adding the setting 'OSC_IDLE_MODE', which turns on the idle enable bit. Then a sleep will put you into 'SLEEP_IDLE'.

So you are selecting SLEEP_FULL already....
Now, you then have the question of 'why a lot of power'.

Multiple things. The first is whether the chip is actually going to sleep?.
The chip will not sleep, if an interrupt is set when you try to sleep.
The next is remember that any pin 'driving' something, will still draw the same power when you go to sleep. Sleep does not turn anything off, except the CPU itself and 'clocked' peripherals. If you have an output driving an LED for instance, and go to sleep with the LED 'on', the LED will stay on, and the current this requires will still be drawn. Before sleeping, _you_ have to put everything else associated with the chip into the low power state. So turn off all outputs driving things. Then make sure that all inputs to the PIC are actually being driven (a floating input can result in extra current being drawn). If fyou have peripheral devices attached to the PIC, they may well need to be programmed 'off' if possible. Also remember that the PIC can only stop it's own oscillator, so if it is running off an external oscillator 'module', this will keep running, unless it has a shutdown pin. For devices like this you would need to switch to the PIC's internal RC oscillator, switch the external oscillator 'off', and only then sleep.
deepakkspdprs



Joined: 09 Mar 2017
Posts: 6

View user's profile Send private message Send e-mail

PostPosted: Sat Mar 11, 2017 3:24 am     Reply with quote

I clearly explain about my problem..

sleep() -->this function is working fine but some problem to be occurred

I have some problem for this function because when I put sleep mode for this function it'll sleep near 10 minutes. After that it'll wake up sometime without our knowledge. So I am gonna study ccs compiler user manual. It's say this function not goes fully sleep.

So I am gonna choose another function, sleep(SLEEP_FULL), but if i use this function its shows error in ccs compiler.

Error is "Expecting a close paren".
temtronic



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

View user's profile Send private message

PostPosted: Sat Mar 11, 2017 6:57 am     Reply with quote

Error is "Expecting a close paren".

That probably NOTHING to do with 'sleep' unless you've not typed in the 'sleep' command properly. I'm thinking you've mistyped the sleep function, and the compiler is not coding for that. What does concern me is that the compiler should NOT complete with that error. It is a fatal error so compiler should NOT create an executable program. IE you cannot burn a PIC with that error and run it.

We'd need to see your current version complete program to see what's going on. You also need to tell us the PIC type and compiler version. As pointed out some PICs don't have all sleep features,some compilers have bugs.

the more you show, the faster we can debug....

Jay
jeremiah



Joined: 20 Jul 2010
Posts: 1349

View user's profile Send private message

PostPosted: Sat Mar 11, 2017 7:45 am     Reply with quote

deepakkspdprs wrote:
I clearly explain about my problem..

sleep() -->this function is working fine but some problem to be occurred

I have some problem for this function because when I put sleep mode for this function it'll sleep near 10 minutes. After that it'll wake up sometime without our knowledge. So I am gonna study ccs compiler user manual. It's say this function not goes fully sleep.

So I am gonna choose another function, sleep(SLEEP_FULL), but if i use this function its shows error in ccs compiler.

Error is "Expecting a close paren".

The wakeup after 10 mins might be from a watchdog timer. Still, we can't even replicate your error because you haven't supplied:

PIC part number
Compiler Version

If you really need help, you need to give us critical information.
benoitstjean



Joined: 30 Oct 2007
Posts: 566
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Sat Mar 11, 2017 7:57 am     Reply with quote

Actually he did provided the PIC part number: 18f67k90

But as TTelmah says, for his PIC chip, the bits are set by default.

Is it the overall circuit drawing 10mA with Sleep() active or the MCU alone?

If it's the overall circuit, then it has nothing to do with the MCU, check your circuit.

Also, there are features you might want to turn-off also before going to sleep like interrupts and timers and such.

Your description of the problem is quite basic and asking for 'urgent' help with almost no information does not help.

Just my two cents worth...

Ben
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sat Mar 11, 2017 9:03 am     Reply with quote

deepakkspdprs wrote:
I clearly explain about my problem..

sleep() -->this function is working fine but some problem to be occurred

I have some problem for this function because when I put sleep mode for this function it'll sleep near 10 minutes. After that it'll wake up sometime without our knowledge. So I am gonna study ccs compiler user manual. It's say this function not goes fully sleep.

So I am gonna choose another function, sleep(SLEEP_FULL), but if i use this function its shows error in ccs compiler.

Error is "Expecting a close paren".


The chip _is_ going to sleep.

The 'expecting a close parenthesis' error, is because your chip does not accept _any_ mode parameter as I already explained. So it sees a parameter, and says 'expecting a close parenthesis'.

It's waking because something triggers it to wake.

Any static interrupt (INT_EXT, IOC etc.), if it triggers will wake the chip up.
The watchdog if enabled, will wake the chip up. etc. etc..

This is not a compiler fault, it's you not understanding what the chip does when it is 'asleep'.
temtronic



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

View user's profile Send private message

PostPosted: Sat Mar 11, 2017 9:41 am     Reply with quote

I'm just confused as to why the compiler does create a runnable program. If I get an error I expect the compiler to 'trap' out, no code created.
To me an error, any error, should stop the compiler,as who is to be the 'code cop' and say do this or do that, based on the error, proceed with the rest of the compile.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sat Mar 11, 2017 3:30 pm     Reply with quote

I don't think it works if he uses the error lines.

He thinks these will give him a deeper sleep, but he is already going fully to sleep (unless he is setting the idle bit in the setup_oscillator, or a interrupt is preventing the sleep). His power consumption is because something else in the circuit is still powered....
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 11, 2017 10:06 pm     Reply with quote

I checked, and his compiler version (4.129) doesn't have any constants
in the 18F67K90.h file for the sleep() function. I got these error messages
for the program below.
Quote:
*** Error 58 "PCH_Test.c" Line 9(7,17): Expecting a close paren
*** Error 58 "PCH_Test.c" Line 11(7,17): Expecting a close paren
2 Errors, 0 Warnings.
Build Failed.


Support could be added by looking at the ASM code for this program
for a modern version of the compiler and writing routines to do the
same thing for vs. 4.129. It involves manipulating bits in the OSCCON
register.

Test program:
Code:
#include <18F67K90.h>
#fuses INTRC_IO,NOWDT
#use delay(clock=4M)

//=====================================
void main(void)
{

sleep(SLEEP_FULL);

sleep(SLEEP_IDLE);

while(TRUE);
}
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