PDA

View Full Version : using sleep in picbasic



flip
- 22nd April 2006, 21:39
I made a small program written in PICBASIC using a PIC 16F628a.

I do not understand how to use the sleep instruction in a correct way.

device 16F628A
Config INTRC_OSC_NOCLKOUT, WDT_OFF,MCLRE_OFF
clear
TRISB.5=1
TRISB.0=0
INTCON=%00011000
OPTION_REG.6=1
OPTION_REG.7=0
SYMBOL LED = PORTB.0
Again:
HIGH LED ' Turn LED on.
DELAYMS 1000 ' Wait 1 second.
LOW LED ' Turn LED off.
DELAYMS 1000 ' Wait 1 second.
HIGH LED ' Turn LED on.
DELAYMS 1000 ' Wait 1 second.
LOW LED ' Turn LED off.
INTCON.1=0
INTCON.0=0
SLEEP
delayms 250
GOTO Again

On port B5 (pin 11) I have connected a switch to wake up the PIC
The led on port b.0 is flashing twice after switching on the power and then the PIC goes asleep.
Waking up through pushing the switch doesn't work.
Who is having any good solution for my problem?

Archilochus
- 22nd April 2006, 21:52
The SLEEP instruction needs a time specified - SLEEP 15 (sleep for 15 seconds - at least in PicBASICPro).

Unless you are trying to use the assembly sleep instruction, then you'd write:

@ sleep

Does PicBASIC (not Pro) support the '@' insruction to insert a single line of assembly?

flip
- 22nd April 2006, 21:59
I tried your suggestion but it is not an improvement, the leds flash twice and the seems to asleep but I can't awake the PIC.

Archilochus
- 23rd April 2006, 15:42
Just curious - is it MELabs PicBASIC that you are using? Some of the commands don't look familiar (I only use the "Pro" version - so can't tell).

If you want to use the PicBASIC SLEEP command (not the assembly command) - you'll need to have the WatchDog Timer set to ON in the config settings.

Arch

flip
- 23rd April 2006, 21:32
I have changed the config setting WD_off in WDT_on
Still my programm is not working properly.
The led is flashing several times, it looks like some inputs of the pic are floating.