| View previous topic :: View next topic |
| Author |
Message |
Marco27293
Joined: 09 May 2020 Posts: 136
|
|
Posted: Mon Dec 14, 2020 5:31 am |
|
|
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
|
|
Posted: Mon Dec 14, 2020 8:16 am |
|
|
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
|
|
Posted: Tue Dec 15, 2020 9:22 am |
|
|
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
|
|
Posted: Tue Dec 15, 2020 11:00 am |
|
|
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. |
|
 |
|