Rookie question


Closed Thread
Results 1 to 2 of 2

Thread: Rookie question

  1. #1
    sacastil's Avatar
    sacastil Guest

    Default Rookie question

    Hi, I just started playing around with PIC chips and I've been having some trouble figuring out the sample code from the website.
    I'm using an 18F4620 and I was looking at the button command sample, where the 3 LEDs on the X2 board will start flickering once a button is pushed.
    Here's the code, just in case,

    Define LOADER_USED 1

    button1 VAR PORTB.4
    button2 VAR PORTB.5
    button3 VAR PORTB.6

    LED1 VAR PORTB.0
    LED2 VAR PORTB.1
    LED3 VAR PORTB.2

    B1 VAR BYTE 'Working buffer 1 for button command
    B2 VAR BYTE 'Working buffer 2 for button command
    B3 VAR BYTE 'Working buffer 3 for button command

    Clear 'Clear buffers
    PORTB = 0 'LEDs off

    TRISB = %11110000 'Set portb 0-3 outputs, 4-7 inputs
    ' OPTION_REG.7 = 0 'Enable PORTB pull-ups



    chk1: Pause 25
    Button button1,0,40,5,B1,0,chk2 ' Check Button 1 (Skip to 2 if Not Pressed)
    Toggle LED1 ' Toggle LED if pressed

    chk2: Button button2,0,40,5,B2,0,chk3 ' Check Button 2 (Skip to 3 if Not Pressed)
    Toggle LED2 ' Toggle LED if pressed

    chk3: Button button3,0,40,5,B3,0,chk1 ' Check Button 3 (Skip to 1 if Not Pressed)
    Toggle LED3 ' Toggle LED if pressed

    GoTo chk1 ' Do it forever

    I found that the chip I'm using does not support the OPTION_REG function and I've been looking for a similar function in the chip manual but didn't find anything or perhaps I wasn't looking at the right place.
    Could anyone suggest anything? or help me out?
    Thank you.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sacastil View Post
    I found that the chip I'm using does not support the OPTION_REG function and I've been looking for a similar function in the chip manual but didn't find anything or perhaps I wasn't looking at the right place.
    Could anyone suggest anything? or help me out?
    Thank you.
    Yes, open the datasheet in Adobe Acrobat Reader...
    Hit Ctrl-F (for find), and type the word
    weak
    in the search box.
    Alternatively, the phrase
    pull-up
    would get you a long way too.

Similar Threads

  1. Remote PIC input question
    By Adrian in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st September 2007, 15:44
  2. Question for a math guru
    By Christopher4187 in forum General
    Replies: 3
    Last Post: - 22nd November 2006, 09:45
  3. Please answer my first question
    By John_001 in forum Off Topic
    Replies: 1
    Last Post: - 15th September 2006, 06:49
  4. Very rookie question
    By dmairspotter in forum General
    Replies: 4
    Last Post: - 7th October 2005, 14:40
  5. Rookie question.. What is this @device command please?
    By David Marks in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st February 2005, 14:59

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