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

PIC18F47J53 CCS C Compiler 5.090 Sleep vs Deep Sleep
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Marco27293



Joined: 09 May 2020
Posts: 136

View user's profile Send private message

PostPosted: Mon Dec 14, 2020 5:31 am     Reply with quote

Now, it seems working :grin:

How can I keep PIN_B2 as output high during sleep?

before I go to sleep I set:

output_high(PIN_B2);

at wake up:

LATB = 0b00000100;
PORTB = 0b00000100;
set_tris_b(0b11111011);

BUT during sleep it goes low... When PIC wake-up enter in a isr which performs a reset_cpu(); command
Ttelmah



Joined: 11 Mar 2010
Posts: 20056

View user's profile Send private message

PostPosted: Mon Dec 14, 2020 8:16 am     Reply with quote

How is the pin used?. Is USB enabled on the device?. If so it is the USB D-
pin and this overrides normal I/O. Or if any #PIN_SELECT makes use of
the pin this too will override the normal I/O. Possibly if the mapped
peripheral is turned off then the pin goes low. #PIN_SELECT overrides
the normal I/O behaviour.

If the pin is setup as a normal I/O pin, then it'ld stay high if set high.

However I'd suspect the most likely thing is that ROSSLP is on. This
means the system 'reference clock' will be output on this pin when the
chip is asleep. However this oscillator will stop in your sleep mode, so it'd
output a static level.
So try:
Code:

#bit ROSSLP=getenv("bit:ROSSLP")

    ROSSLP=0; //disable reference oscillator output
Marco27293



Joined: 09 May 2020
Posts: 136

View user's profile Send private message

PostPosted: Tue Dec 15, 2020 9:22 am     Reply with quote

Thank you Ttelmah,

Last question, now I'm controlling wdt via software in this way:
Code:

#FUSES NOWDT

setup_wdt(WDT_ON);
setup_wdt(WDT_4S);
....
setup_wdt(WDT_OFF);

using:
Code:

#FUSES NOWDT, WDT1024

setup_wdt(WDT_ON);
....
setup_wdt(WDT_OFF);

will be the same or will I lose WDT software control?

Regards,

Marco
Ttelmah



Joined: 11 Mar 2010
Posts: 20056

View user's profile Send private message

PostPosted: Tue Dec 15, 2020 11:00 am     Reply with quote

No, it is only the enable bit that overrides software control.
Setting the division in the fuses is actually being done for you.
The prescaler is only settable by the fuses. When you add the line:

setup_wdt(WDT_4S);

The compiler automatically sets the fuses to give the 4 second nominal
timing. If you look at the .lst file with this set, you will find /1024 is
set.

This is why you can't actually 'change' the timing. Once it is set, it is
fixed in the fuses.
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 Previous  1, 2
Page 2 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