The worst programmer ever to grace this forum - ME!


Results 1 to 40 of 50

Threaded View

  1. #17
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Ok, a bit more reading .... it seems the button command will be perfect for needs.

    My initial problem is that it only acts on PORTB pins (& the Pickit 2 board has its switch wired to RA3). therefore I've rigged up a pull up resistor onto pin RB7 & a small switch which goes to ground (therefore puts 0V onto RB7 when this new switch pressed). However RB7 is being held low all the time.

    I'm figuring this must be something to do with the .inc file again (I've rechecked my wiring - it's fine ...10k resistor between RB7 & the 5V rail....and a normally open switch going from RB7 to ground). I chose RB7 for my new switch as it seemed to have the least happening! On the datasheet it's listed as RB7/TX/CK ...how can I be sure it's being used as an input pin only (& not being overridden by one ithe pins other purposes)

    Does anyone have any ideas why my RB7 might be permanently low.

    Here's the small bit of code I'm using...

    @MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON
    @MyConfig = MyConfig & _MCLRE_OFF & _BOR_OFF
    @ __config MyConfig

    DEFINE OSC 4
    ANSEL=0 ' all digital
    ANSELH=0 ' analog module disabled
    CM1CON0=0 ' dunno what this line does!
    CM2CON0=0 ' nor this one!
    TRISA=%11111111 ; set all Port A pins as inputs
    TRISB=%11111111 ; set all Port B pins as inputs
    TRISC=%00000000 ; set all Port C pins as outputs

    B0 VAR BYTE ;creates a variable as needed for the button command below
    B0 = 0 ; give it a value of zero (as per the command's reference)

    LED1 var PortC.0 ' ; assign a more usable name to the first LED port

    start:
    LOW LED1 ; turn the first LED off

    BUTTON 7, 0, 255, 0, B0, 1, Loop ; monitor the switch on RB7 for 0V,
    ;if this condition is net, then go to next

    next:
    high LED1 ; turn the first LED on
    PAUSE 1000 ; wait one second
    goto start ;start over
    End
    Last edited by HankMcSpank; - 16th March 2009 at 00:39.

Similar Threads

  1. Melabs U2 Programmer Command Line Options
    By Robert Wells in forum General
    Replies: 5
    Last Post: - 3rd July 2009, 02:11
  2. problems with USB programmer
    By malc-c in forum General
    Replies: 7
    Last Post: - 10th May 2007, 20:14
  3. USB programmer problems
    By uiucee2003 in forum USB
    Replies: 2
    Last Post: - 15th August 2006, 23:47
  4. General Programmer Questions
    By mslaney in forum General
    Replies: 1
    Last Post: - 17th December 2004, 18:16

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