16f876a


Closed Thread
Results 1 to 5 of 5

Thread: 16f876a

  1. #1
    DanS.'s Avatar
    DanS. Guest

    Default 16f876a

    Hi,
    New to the forum in terms of posting, but I find many of you good folks very helpful in your ideas. Thanks!
    I am having problems with the 16f876a. Stripped my code to simply read a pin and drive another pin based on state.

    Seems like my boot LED does it's count OK and then the processor just runs out into the weeds! Is there anything outstanding about the 876A?

  2. #2
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Dan,

    If you've read this forum enough you should see that guessing at how a program works or doesn't work doesn't do you or us any good and you are just wasting time. How about giving us something to work with like a listing of the code you are trying to run for starters. Also perhaps a schematic of how you have hooked up your test circuits to the PIC. Maybe then we can help you.

    BobK

  3. #3
    DanS.'s Avatar
    DanS. Guest


    Did you find this post helpful? Yes | No

    Default

    Bob,
    Thanks for the responce. I was starting out with a curiosity about possible known issues with the 876A and PBP / U2 programmer? Sorry for the vague question.

    The source shown here is a stripped out version to test basic function of the circuit and compiler.

    10meg osc is doing it's job. Power is clean @ 5V. Been over the hardware and PCB layout and is error free.

    I can flash the LED if I remove the if tpin test. With the IF Then, the thing seems dead!

    '''''''''''''hardware setup''''''''''''''''''''''
    @ device pic16f876a, debug_off, hs_osc, wdt_off, pwrt_on, bod_off, protect_off
    CMCON = 7 'disable adcs, porta = digital
    define osc 10 'external clock 20 mhz '''

    '''''''''''''''''''''''port setup''''''''''''''''''''''
    TRISA.0 = 1
    TRISA.1 = 1
    TRISA.2 = 1
    TRISB.0 = 0
    TRISB.1 = 0
    TRISB.2 = 0
    TRISB.3 = 0
    TRISB.4 = 0
    TRISB.5 = 0
    TRISB.6 = 1
    TRISB.7 = 1
    TRISC.0 = 1
    TRISC.1 = 1
    TRISC.2 = 1
    TRISC.3 = 1
    TRISC.4 = 1

    '''''''''''''''''define''''''''''''''''''''''''
    z1_relay VAR PORTB.0
    z2_relay VAR PORTB.1
    z3_relay VAR PORTB.2
    z4_relay VAR PORTB.3
    z5_relay VAR PORTB.4
    z6_relay VAR PORTB.5
    z1_read VAR PORTB.6
    z2_read VAR PORTB.7
    z3_read VAR PORTC.3
    z4_read VAR PORTC.2
    z5_read VAR PORTC.1
    z6_read VAR PORTC.0
    stat_led VAR PORTC.4
    'conn40 var PORTA.0
    conn41 var PORTA.1
    conn42 var PORTA.2
    lcd_tx var PORTC.6
    serial_rx var PORTC.7
    tpin var PORTA.0
    '''''''''''''''reg defines''''''''''''''''''''''''
    i var byte
    therm_status var byte
    'therm_calc1 var byte
    'therm_calc2 var byte
    'water_temp var byte
    'cyc_count var word
    'ondelay_1 var BYTE
    'ondelay_2 var word
    'therm_result var byte
    'suspend var Byte
    '''''''''''''''''''''''''''''''''''''''''''''''''' '

    main:
    if tpin = 0 then main
    low stat_led
    pause 500
    high stat_led
    pause 500
    goto main
    end

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


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by DanS.
    ... then the processor just runs out into the weeds! ...
    1) What is connected to pin 1?

    2) consider adding ADCON1 = 7
    Last edited by paul borgmeier; - 14th October 2006 at 04:15.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  5. #5
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi,

    Paul's reply is very important. Also do you have pull up or pull down resistors on your inputs?

    You can save some typing by setting up your ports like this:
    TRISA = %00000111 '1 = input 0 = output
    TRISB = %11000000
    TRISC = %00000000

    Just looking at your Main program, "If tpin = 0 then main" says if the input pin is grounded or low just loop here until it's high. If it's high then pulse the LED on and off until the tpin is low again. Without plugging this program into a board here it should seem it would work BUT as Paul said what have you done with pin 1 and did you set ADCON1 to 7.

    In your "hardware setup" you have CMCON = 7 'disable adcs, porta = digital.

    All "CMCON = 7" does is disable the comparators.

    "ADCON1 = 7" disables the analog ports making them digital.

    Pin 1 is the MCLR input and needs to be made high through at least a 1K resistor. You should also have .01uF capacitors across the + and - power pins as close as possible and also one between the MCLR pin and ground.

    I'm going to work now so try these things out and see if your PIC doesn't work better.

    You're only learning now!

    Have a nice day!

    BobK

Similar Threads

  1. Problem with 16F877A but not with 16F876A
    By savnik in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 16th May 2008, 14:18
  2. 16f876a Pwm
    By Hainkm in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th December 2007, 17:33
  3. 16F876A Configuration
    By RFEFX in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th November 2006, 18:30
  4. Pwm 16f876a
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th September 2006, 06:35
  5. EPIC Programmer - Works for all chips but the 16F876A
    By 4Lewis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th April 2006, 23: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