Simple problem?


Closed Thread
Results 1 to 6 of 6

Thread: Simple problem?

  1. #1
    Join Date
    Aug 2006
    Location
    Arizona
    Posts
    5

    Question Simple problem?

    Hi,
    I can't figure out what I'm sure is a simple solution to my problem. I have a NO button that I am trying to just turn on/off an led. I'm using PicBasic (not the pro version) and a 16F818 chip. I've attached my schematic and my code follows. My problem is: when I first power up LEDa and LEDb light up, and when I push the button LEDb turns off and LEDa stays on. My code has nothing to do with LEDb (B1), yet pushing the button affects it. And LEDa stays on constantly. Here's my code:

    POKE $8F,%01100000 'SET CLOCK SPEED @4MHZ
    SYMBOL TrisB=$86 'PortB data direction Address
    SYMBOL PortB=$06 'PortB Pin Address
    SYMBOL led=Pin0
    SYMBOL pb=Pin7

    Poke TrisB,128 'portB 0 to 6 outputs, 7 input

    Poke PortB,0 'All off to start
    Pause 1000

    Start:
    If pb=1 then light '??
    LOW led 'LED off
    GOTO Start 'Return to start

    light:
    High led 'LED on
    GOTO Start 'Return to start

    END

    Thanks in advance,
    Ed
    Attached Images Attached Images
    Last edited by FastEddie; - 2nd March 2007 at 05:26.

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Code:
    High Pin0
    is not allowed (or in your case High led) – it must be
    Code:
    High 0
    (see manual)

    The same goes for Low command

    Let us know ...
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    make sure of your config fuses setting, LVP mode must be disabled, and you must select the internal OSCillator as well.

    once done, you must set the internal OSC to 4MHZ, by default it's 32KHz... pretty slow...
    Code:
    Poke $8F, $60
    i don't know if PBC support the configuration fuse setting, but you could add the following at the top of your code to see if it return you any error..
    Code:
    @ DEVICE PIC16F818, INTRC_OSC_NOCLKOUT
    @ DEVICE PIC16F818, WDT_OFF
    @ DEVICE PIC16F818, MCLR_ON
    @ DEVICE PIC16F818, BOD_ON
    @ DEVICE PIC16F818, LVP_OFF
    @ DEVICE PIC16F818, CPD_OFF
    @ DEVICE PIC16F818, WRT_OFF
    @ DEVICE PIC16F818, DEBUG_OFF
    @ DEVICE PIC16F818, CCPMX_OFF
    @ DEVICE PIC16F818, PROTECT_OFF
    Last edited by mister_e; - 2nd March 2007 at 15:41.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    He is all set with the Poke $8F, $60 (his first line of code is this)

    You cannot use @ Device as Steve noted but the workaround is documented here in posts 34 and 35 here

    http://www.picbasic.co.uk/forum/showthread.php?t=543

    Best,
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier View Post
    He is all set with the Poke $8F, $60 (his first line of code is this)
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Aug 2006
    Location
    Arizona
    Posts
    5


    Did you find this post helpful? Yes | No

    Smile

    Thanks paul and mister e for answering. I did what paul said and it worked. I guess I thought when I used SYMBOL I could reference it using that. I should've read the book.

    Thanks again,
    Ed

Similar Threads

  1. Simple USB Comms Problem
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th January 2010, 20:17
  2. Simple program - Strange problem!
    By Megahertz in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 19th December 2009, 22:52
  3. 16F676 Really simple, stupid problem - Help!
    By Jayhovah in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 1st May 2008, 03:28
  4. PIC18F4525 & LCD simple code problem
    By aggie007 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd November 2007, 16:29
  5. Need help on pic to pic flow control (simple problem I think)
    By khufumen in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th January 2006, 00:34

Members who have read this thread : 0

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