using sleep in picbasic


Closed Thread
Results 1 to 5 of 5
  1. #1
    flip's Avatar
    flip Guest

    Default using sleep in picbasic

    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?

  2. #2
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    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?

  3. #3
    flip's Avatar
    flip Guest


    Did you find this post helpful? Yes | No

    Default using sleep

    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.
    Last edited by flip; - 22nd April 2006 at 21:34.

  4. #4
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    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

  5. #5
    flip's Avatar
    flip Guest


    Did you find this post helpful? Yes | No

    Default using sleep command

    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.

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 07:12
  3. 16F628A current high during sleep
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th October 2006, 10:21
  4. Wierd sleep issue
    By orca in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th March 2006, 22:06
  5. PicBasic Fundamentals
    By Billyc in forum General
    Replies: 9
    Last Post: - 4th May 2004, 10:04

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts