Noobie programmer


Closed Thread
Results 1 to 12 of 12
  1. #1
    noobie's Avatar
    noobie Guest

    Default Noobie programmer

    Hi! I am currently a new programmer programming a PIC16C745 IC. Can any people out there take a look at my code and advice me what is wrong.I am trying to detect an input at RB0 and give an output and RB5. Thanks!

    #include <p16c745.inc>

    #define LED PORTB,5 ;
    #define switch PORTB,0 ;


    ORG 00H ;
    BCF STATUS, RP1 ;
    BCF STATUS, RP0 ;
    CLRF PORTB ; Initialize PORTB by
    ; clearing output
    ; data latches
    BSF STATUS, RP0 ; Select Bank 1
    MOVLW 06H ; Configure all pins
    MOVWF ADCON1 ; as digital inputs
    MOVLW 0xCF ; Value used to
    ; initialize data
    ; direction
    MOVWF TRISB ; Set RB<3:0> as inputs
    ; RB<5:4> as outputs
    ; TRISB<7:6> are always
    ; read as ’0’.
    GOTO main ;
    main BTFSS switch ;
    GOTO $-1 ;
    BSF LED ;
    BTFSC switch ;
    GOTO $-1 ;
    BCF LED ;
    GOTO main ;

    end
    Last edited by noobie; - 27th April 2006 at 10:07.

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


    Did you find this post helpful? Yes | No

    Smile

    One problem with your quest for a solution is that you have posted in a PicBasic language Forum and not an Assembly language Forum. Try posting your question here

    http://forum.microchip.com/

    However, everything looks fine to me with your code – it should work. When you repost in the microchip forum, make sure to describe what is not working. Does the chip just do nothing? Does your chip program without error? What is providing the highs and lows on PORTB.0? What configs did you set? Do you have a schematic to post? etc.

    Good Luck,

    Paul Borgmeier
    Salt Lake City, Utah
    USA

  3. #3
    noobie's Avatar
    noobie Guest


    Did you find this post helpful? Yes | No

    Default Thanks

    Just a manual switch at port B,0 that is providing a high then i expect port B,5 to output a high when port B,0 is detected high to light up a LED. Thanks for telling me the exact forum to post. If u know what's wrong for the logic of my program pls reply me. Thanks!

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    noobie,

    I think it's just a banking problem.

    Before entering the Main loop, you change to bank1 and load ADCON1 and TRISB. Then in the loop you are testing and trying to set bits in PORTB, which is in bank0 or bank2.

    Put a clrf STATUS before entering the loop and it should work better.
    <br>
    DT

  5. #5
    noobie's Avatar
    noobie Guest


    Did you find this post helpful? Yes | No

    Default CLRF STATUS be4 entering loop

    I tried it out but to no avail. Output RA4 still dun hav a high...

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    RA4 ???

    Your output was RB5.
    <br>

  7. #7
    noobie's Avatar
    noobie Guest


    Did you find this post helpful? Yes | No

    Default Sorry

    Sorry i made a mistake... Should be RB5 do not hav a high output...

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Then, may I ask exactly where you put the line?

    AND
    Just a manual switch at port B,0 that is providing a high ...
    Does it have a pull-down resistor to provide a low when the switch is not pressed?
    <br>

  9. #9
    noobie's Avatar
    noobie Guest


    Did you find this post helpful? Yes | No

    Default Yup

    I did have a pull up resistor so that it is a low when the switch is not press.
    I place the CLRF STATUS before GOTO main

  10. #10
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Then you're left with Paul's other questions ...
    Does your chip program without error?
    What configs did you set?
    Along with ...

    Are you using a 6mhz crystal?
    Is the oscillator config set to HS or H4? (16C745 doesn't have XT mode)
    What size capacitors are on the crystal? (normally 22pf)
    Is it a valid crystal, and is it actually oscillating?
    Is there a pull-up resistor on MCLR?
    Do you have 5V to VDD?
    Are both VSS pins connected to ground?

    Sorry for the basic questions but, it doesn't matter how good the program is, if the hardware isn't running.
    <br>
    DT

  11. #11
    noobie's Avatar
    noobie Guest


    Did you find this post helpful? Yes | No

    Default Got it

    Sorry Guess noobie fault... I didn't pluck in the oscillator... Embarrased that i made this kind of stupid fault...

  12. #12
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Not to worry, just chalk it up as something you won't do next time.

    Eventually, you'll have made every possible mistake already, and you'll write Perfect bug free code. &nbsp; But, in the mean time, plan on having at least one of those "ooops" reactions in every project you do.

    I still do.
    <br>
    DT

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. Melabs USB Programmer
    By tmurph in forum General
    Replies: 1
    Last Post: - 25th December 2005, 03:25
  5. General Programmer Questions
    By mslaney in forum General
    Replies: 1
    Last Post: - 17th December 2004, 18:16

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