Blink Programme for 16F876


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

    Question Blink Programme for 16F876

    My first project.

    PicBasic Pro + Microcode Studio Plus v2.1.0.8 + Epic Plus Programmer + Prototype Board + XT 4Mhz

    Tried first setup with C508 and BLINK.BAS programme no problem.

    Selected different processor and successfully loaded programme into F876.

    Can turn outputs ON at any pin position, but when i use the PAUSE instruction and any time setting within the programme nothing runs at all.

    What am doing wrong?

  2. #2
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    banjaxxed

    see: here
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    1. Read the Datasheet.

    2. You will discover the F876 has ADC's (and Comparators I believe in the case of the A version). By default, PortA comes up in Analogue mode. You must set the pins to Digital. See the sections for A/D Convertor Module (and Comparator Module section if it has one) to see how to do this.

    I really am trying to force people to read the Datasheets (the solution is very simple) before asking for answers on the forum.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    read the Datasheets
    And if it still doesn't work -- take a peek at the "errata sheet"....;o]
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    And by the time you've done that, you'll discover the part has been obsoleted by the 'A' version!

  6. #6
    banjaxxed's Avatar
    banjaxxed Guest


    Did you find this post helpful? Yes | No

    Default

    after spending a fortune, getting no answers or support from my suppliers... only more questions - in getting this thing going...... i'll be obsolete myself before it's over

    (should have spent my hundreads of pounds on a decent micro plc)

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Post your code that's not working with a note on your config fuse settings.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8
    banjaxxed's Avatar
    banjaxxed Guest


    Did you find this post helpful? Yes | No

    Thumbs up 16F876 PicBasic Pro Program Fault Corrected For Blink

    <thanks to all for any advice>

    After a long hair pulling session, figured out the 16F876 starts with the A/D running. I wanted digital out Pin 22 (RB1). This is turned off by command 'ADCON1=7' line.

    Working code below to save someone else fustration:

    ' Ricky V
    ' 28 March 2005
    ' Blink Program
    ' MCU PIC16F876
    ' Rev 56,098,345

    DEFINE OSC 4

    ADCON1=7 'disable analogue to digital converter
    TRISB = 0 'set all pins on Port B to outputs
    LED VAR PORTB.1 'Sets which PIN the LED is on, Pin 22 +5V

    loop:
    High LED ' Turn on LED connected to PORTB.1 as Set in VAR LED
    Pause 500 ' Delay for .5 seconds
    Low LED ' Turn off LED connected to PORTB.1 as Set in VAR LED
    Pause 500 ' Delay for .5 seconds
    Goto loop ' Go back to loop and blink LED forever

    End
    =-=-=-=-=-=-=-=-==-=-==-=--=-=-=-=-=-=-==-=-=-=-=-==-

  9. #9
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    I'm glad to hear you got it working, but ADCON1 has no affect on PORTB.

    PORTA is the 16F876 A/D port.

    AN4 = RA5
    AN3 = RA3
    AN2 = RA2
    AN1 = RA1
    AN0 = RA0
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  10. #10
    4Lewis's Avatar
    4Lewis Guest


    Did you find this post helpful? Yes | No

    Default Same Code for blink 16F876A and "not working"

    I used your exact code (which I know works just from looking at it) and I get this error "Code Programming error at 0000" - any suggestions, help?

    -------------------------------
    DEFINE OSC 4

    TRISB = 0 'set all pins on Port B to outputs
    LED VAR PORTB.1 'Sets which PIN the LED is on, Pin 22 +5V

    loop:
    High LED ' Turn on LED connected to PORTB.1 as Set in VAR LED
    Pause 500 ' Delay for .5 seconds
    Low LED ' Turn off LED connected to PORTB.1 as Set in VAR LED
    Pause 500 ' Delay for .5 seconds
    Goto loop ' Go back to loop and blink LED forever

    End
    ------------------------------

  11. #11
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Your device programmer should have a help file listing several possible causes
    for this particular error message. Lots of things can cause this one. Have you
    worked through the list in the help file?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  12. #12
    4Lewis's Avatar
    4Lewis Guest


    Did you find this post helpful? Yes | No

    Default solution is simple

    The problem was simple (once I got the installation documentation)

    My Zif programmer is screwed down to a board, so I couldn't turn it around. NOW, I know what was happening and why.

    I didn't just put my chip in a different direction, I had to turn aroud the Zif programmer and move the cable connector to the other side as well. So my school gave me a new programmer that was't screwed down so I could do that. It was simple, so I feel silly but all ends well.

Similar Threads

  1. Trouble with most basic BLINK on PIC 16F819
    By confusedperson in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 16th April 2009, 22:46
  2. Simple Blink program doesnt work.
    By sccoupe in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 1st March 2009, 21:30
  3. Can't get blink circuit to work :(
    By Techbuilder in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 31st January 2008, 14:00
  4. Execution time in programme
    By Adrian in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th November 2007, 23:29
  5. I Just Can't Get it to Blink - 16F628
    By Spindle in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 31st May 2005, 16:54

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