Help with the Sleep Mode function,please (DSIC33EP..)

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
User avatar
celebriums
Posts: 125
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 71 times
Been thanked: 33 times
Contact:

Help with the Sleep Mode function,please (DSIC33EP..)

Post by celebriums »

Hi All

C code into "Sleep ();" Code and compile it, I get the following error. Could you help me? Please
Thank you.

MCU:(DSPIC33EP128MC206)

..
Description:
Device: PIC16.33E.33EP128MC206
Generated by: Flowcode v7.1.1.0
Date: Tuesday, December 27, 2016 02:15:23
Users: 1
Registered to: celebrium
Licence key: 86ER3C
http://www.flowcode.co.uk
Launching the compiler...
C:\Program Files (x86)\Flowcode 7\compilers\pic16\batchfiles\pic16_C30_comp.bat "TTS Test" "E:\Yandex\(RFELE~2\software\" "33EP128MC206"
Launching compiler...

E:\Yandex\(RFELE~2\software>xc16-gcc -c -mcpu="33EP128MC206" -funsigned-char -fno-short-double -Os -I"C:\PROGRA~2\FLOWCO~3\COMPIL~1\pic16\BATCHF~1\..\support\h" -I"C:\PROGRA~2\FLOWCO~3\COMPIL~1\pic16\BATCHF~1\" -std=gnu99 "TTS Test".c -o "TTS Test".o
Options have been disabled due to restricted license
Visit http://www.microchip.com/ to purchase a new key.
TTS Test.c: In function 'main':
TTS Test.c:157:2: warning: implicit declaration of function 'sleep'
TTS Test.c: At top level:
TTS Test.c:208:1: warning: '_FICD' definition has been deprecated: consider migrating to #pragma config
TTS Test.c:208:1: warning: '_FPOR' definition has been deprecated: consider migrating to #pragma config
TTS Test.c:208:1: warning: '_FWDT' definition has been deprecated: consider migrating to #pragma config
TTS Test.c:208:1: warning: '_FOSC' definition has been deprecated: consider migrating to #pragma config
TTS Test.c:208:1: warning: '_FOSCSEL' definition has been deprecated: consider migrating to #pragma config
TTS Test.c:208:1: warning: '_FGS' definition has been deprecated: consider migrating to #pragma config

Compilation successful!
Completed compilation, return = 0

Launching the linker/assembler...
C:\Program Files (x86)\Flowcode 7\compilers\pic16\batchfiles\pic16_C30_link.bat "E:\Yandex\(RFELE~2\software\TTS Test" 33EP128MC206 33E


xc16-ld 1.26 (A)

Program Memory [Origin = 0x200, Length = 0x155ec]

section address length (PC units) length (bytes) (dec)
------- ------- ----------------- --------------------
.text 0x200 0xe4 0x156 (342)
.text 0x2e4 0x21e 0x32d (813)
.init.delay32 0x502 0x1c 0x2a (42)
.dinit 0x51e 0xe 0x15 (21)
.shared.dinit 0x52c 0x2 0x3 (3)

Total program memory used (bytes): 0x4c5 (1221) <1%


Data Memory [Origin = 0x1000, Length = 0x4000]

section address alignment gaps total length (dec)
------- ------- -------------- -------------------
.nbss 0x1000 0 0x4 (4)
.bss 0x1004 0 0x14 (20)

Total data memory used (bytes): 0x18 (24) <1%


Dynamic Memory Usage

region address maximum length (dec)
------ ------- ---------------------
heap 0 0 (0)
stack 0x1018 0x3fe8 (16360)

Maximum dynamic memory (bytes): 0x3fe8 (16360)

E:\Yandex\(RFELE~2\software\TTS Test.o(.text+0x21a): In function `_main':
: undefined reference to `_sleep'

Error returned from [xc16-gcc.exe]

C:\Program Files (x86)\Flowcode 7\compilers\pic16\batchfiles\pic16_C30_link.bat reported error code 1



FINISHED
Attachments
TTS Test.fcfx
(7.69 KiB) Downloaded 317 times
Sincerely Regards
Sadık SUME

www.kaandesign.com.tr

User avatar
celebriums
Posts: 125
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 71 times
Been thanked: 33 times
Contact:

Re: Help with the Sleep Mode function,please (DSIC33EP..)

Post by celebriums »

Hi Benj
I hope your answer this questions. Thank you.

"Sleep mode is the lowest current-consumption state. The characteristics of Sleep mode include
the following:
Step 1.) The Primary Oscillator (POSC) and internal FRC oscillator are disabled..."

The compiler gives an error when I write the code as follows.
set_bit (FOSC,1);
set_bit (FOSC,0);

How do I set the FOSC?

Section 7. Oscillator
http://ww1.microchip.com/downloads/en/D ... 70580C.pdf (page7)

Note:
Setting OSCCON and RCON does not give an error.


links:
http://ww1.microchip.com/downloads/en/DeviceDoc/S8.pdf
http://ww1.microchip.com/downloads/en/DeviceDoc/S9.pdf





9.2.2.1 SLEEP MODE
Sleep mode is the lowest current-consumption state. The characteristics of Sleep mode include
the following:

• The Primary Oscillator (POSC) and internal FRC oscillator are disabled

• The Secondary Oscillator (SOSC) continues to run if the Secondary Oscillator Enable bit
(LPOSCEN) in the Oscillator Control register (OSCCON<1>) is set. For details, refer to

Section 7. “Oscillator” (DS70580) in the “dsPIC33E/PIC24E Family Reference Manual”.

• The WDT, clock source and LPRC oscillator continue to run if the Watchdog Timer is
enabled. The WDT, if enabled, is automatically cleared prior to entering Sleep mode. For
details, see 9.3 “Watchdog Timer”.

• If the Voltage Regulator Standby Enable bit (VREGS) is cleared in the Reset Control
register (RCON<8>), the internal voltage regulator enters the Stand-by state. The voltage
regulator consumes a reduced amount of current in the Stand-by state.

• If the Flash Memory Voltage Regulator Stand-by Enable bit (VREGSF) in the Reset Control
register (RCON<11>) is cleared, the voltage regulator that powers the Flash memory
enters the Stand-by state. The Flash voltage regulator consumes a reduced amount of
current in the Stand-by state.

• The peripherals operating with the system clock are disabled

• The Fail-Safe Clock Monitor (FSCM) does not operate during Sleep mode, because the
system clock is disabled
To minimize current consumption in Sleep mode, do the following:

Ensure that I/O pins do not drive resistive loads

• Ensure that I/O pins configured as inputs are not floating

• Disable the SOSC

• Disable the WDT

• Enable the voltage regulator to enter Stand-by state in Sleep mode
When the device exits Sleep mode, it restarts with the current clock source as indicated by the Current
Clock Source Selection bits (COSC<2:0>) in the Oscillator Control register (OSCCON<14:12>).
Attachments
TTS Test 2 .fcfx
(18.67 KiB) Downloaded 323 times
Sincerely Regards
Sadık SUME

www.kaandesign.com.tr

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: Help with the Sleep Mode function,please (DSIC33EP..)

Post by LeighM »

Hi, to sleep, try something like this

Code: Select all

asm("PWRSAV #SLEEP_MODE");

User avatar
celebriums
Posts: 125
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 71 times
Been thanked: 33 times
Contact:

Re: Help with the Sleep Mode function,please (DSIC33EP..)

Post by celebriums »

LeighM wrote:Hi, to sleep, try something like this

Code: Select all

asm("PWRSAV #SLEEP_MODE");

Thank you for your answer LeighM.

Could you install and compile TTSTest2.fcfx which I installed?

The code you wrote is giving a error code.
Sincerely Regards
Sadık SUME

www.kaandesign.com.tr

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: Help with the Sleep Mode function,please (DSIC33EP..)

Post by LeighM »

Hi,
I've just checked the header file for this device and found that the C function you need is Sleep(); not sleep();

Alternatively, it looks like the constants for SLEEP_MODE and IDLE_MODE are 0 and 1

Post Reply