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 restart_cause info

 
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: 126

View user's profile Send private message

PIC18F47J53 CCS C Compiler 5.090 restart_cause info
PostPosted: Tue Oct 13, 2020 4:43 am     Reply with quote

Good morning,

Is it possible to exit deep sleep using ext1 interrupt remapped on PIN_C1 ?

If yes, will restart_cause() return EXT_FROM_DS ?

During deep sleep is it possible to keep high PIN_B2 in order to keep enabled a voltage switch (required to supply the peripheral which eventually trigger the isr on PIN_C1) ?

regards
temtronic



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

View user's profile Send private message

PostPosted: Tue Oct 13, 2020 5:13 am     Reply with quote

quick reply..

While I've never had any PIC goto sleep in 2.5 decades, I was curious, downloaded the datasheet. section 4.6.2(page 56..) does explain it ! yes, a pin set high before will remain high.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Tue Oct 13, 2020 5:13 am     Reply with quote

Yes.

The pin if set to drive high, will remain driving high. You will have to
ensure your wake up code does not change this if you want it to remain
driving high. You need to clear the 'RELEASE' bit to allow normal I/O.
The compiler will probably do this.
INT1 will need to be setup with PPS to this pin (just to confuse CCS calls
this INT1).
Obviously any current drawn on B2, will increase the sleep current.
Marco27293



Joined: 09 May 2020
Posts: 126

View user's profile Send private message

PostPosted: Tue Oct 13, 2020 5:23 am     Reply with quote

Thanks,

I do not clearly understand: Will restart_cause() return EXT_FROM_DS ?

regards
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Tue Oct 13, 2020 6:12 am     Reply with quote

Yes.
But when you re-awaken, the I/O pins wil be locked in the state they were
when you went to sleep, until 'RELEASE' is cleared/ So you need to
program their I/O levels and state, restore your variables and then clear this bit.

Understand, if you program a variable like:
Code:

int8 a_variable=10;

This will be set to '10' when the chip boots or restarts from deep sleep.
However if you code like
Code:

int8 a_variable;
#bit RELEASE=getenv("bit:RELEASE")

void main(void)
{
    int16 cause;
    cause=restart_cause();
    if (cause==MORMAL_POWER_UP || cause==MCLR_FROM_RUN)
    {
        //set all your variables to the 'power on' values
        a_variable=10;
        //etc..
    }
    else if (cause==EXT_FROM_DS)
    {
        //set all your variables to their 'running' values
        a_variable=read_eeprom(0); //using EEPROM for example
        //etc..
        out[ut_high(xxx); //etc.
        RELEASE=0; //release I/O pins back to program control
    }
    else if (cause==WDT_TIMEOUT || cause==BROWNOUT_RESTART)
    {
         //here variables won't have been lost can leave as they are

    }
    //main code

}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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