Menu

cannot get 16f876a to work

Help
2009-01-03
2013-05-30
  • Nobody/Anonymous

    Hi, this is my code:

    'General hardware configuration
    #chip 16F876A, 4
    #config XT_OSC, WDT_OFF, LVP_OFF, BODEN_OFF, PWRTE
    #mem 368

    DIR PORTC OUT

    MAIN:
    set PORTC.4 on
    Wait 1 s
    set PORTC.4 off
    Wait 1 s
    goto MAIN

    All the chip does is sit there.  I have an external 4mhz crystal attached with 18pf capacitors.  It's got power, it just doesn't seem to be running anything.  I've tried all sorts of configurations, but nothing seems to work.

     
    • kent_twt4

      kent_twt4 - 2009-01-03

      The compiler now handles device memory, so no need now for #mem 368.

      Is the PIC Vdd and Vss bypassed by 0.1uf cap as close to the device as possible?  Also place the crystal as close to OSC1 and OSC2 pins as possible.

      Trying HS_OSC probably doesn't do anything for you?  Some crystals require higher load capacitors, like 20-22pf (your 18pf's should be good).  No problems with a 16f877A and cheapo 4 mhz crystal and 20pf caps, XT or HS_OSC.

      Other things to check:
      Is the PIC actually programmed, can you read back the program memory?
      Bad crystal?  Try another, or different speed.

       
    • Nobody/Anonymous

      I am using a board from modtronix. 

      This is the board:
      http://www.modtronix.com/product_info.php?cPath=1_50&products_id=256

      I got it hoping that I would not have to fool with the hardware.  I used the same crystal that the data sheet said I could use.  The program does download to the pic because I can read it and it's there.

      I didn't know if my problem was a hardware issue, like with the crystal, or if I the software was wrong in some way.

       
    • Nobody/Anonymous

      try to change the program to use internal oscillator.
      see if it works then ?

       
    • Santiago

      Santiago - 2009-01-24

      I think you have to use HS_OSC instead of XT_OSC

      And PWRTE must be PWRTE_ON or PWRTE_OFF

      May be there are the problems...

       
    • Santiago

      Santiago - 2009-01-24

      This code worked ok for me (in real circuit):

      'General hardware configuration
      #chip 16F876A, 4
      #config HS_OSC, WDT_OFF, LVP_OFF, BODEN_OFF, PWRTE_ON
      #mem 368

      DIR PORTC OUT

      MAIN:
      set PORTC.4 on
      Wait 1 s
      set PORTC.4 off
      Wait 1 s
      goto MAIN

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.