16f877a issues - Page 1
Forum section: electronics / general

author: Etesla
author_rank: Regular Contributor
timestamp: September 16, 2017, 11:49:21 pm
content: I am trying to make an led blink with a pic 16f877a using mikroc, mplab ipe, and a pickit 3. I have made led's blink on four different pic micro's, but the 877 is giving me some trouble. The pictures are screenshots of my code, the config bits, and a schematic showing how I hooked up the crystal (ignore the led being on port C in the schematic, I have mine on pin 2, promise). Some things to note: The code builds fine, loads into the mplab ipe fine, and programs fine. None of the pins on port A light the led. I have tried all the other ports with the same disappointing results. I used a 16 mhz crystal if that makes a difference. Any advice is appreciated. Thanks!

author: woody
author_rank: Frequent Contributor
timestamp: September 17, 2017, 09:51:50 am
content: Try enabling the Power Up timer (PUT).Paul

author: StillTrying
author_rank: Super Contributor
timestamp: September 17, 2017, 02:50:34 pm
content: Is the uP actually powered, and the power 100nF decoupled.

author: ggchab
author_rank: Frequent Contributor
timestamp: September 17, 2017, 02:57:55 pm
content: LED is on PortC (RC1) and you access PortA in your code !?Also, it's better to use LAT instead of PORT to write to a port.

author: sasa
author_rank: Regular Contributor
timestamp: September 17, 2017, 03:23:37 pm
content: Quote from: ggchab on September 17, 2017, 02:57:55 pmAs well, I have just noted ports are switched, thus I will comment rest...IIRC, LAT is not present in PIC16 MCUs.Also, usual value of resistor on MCLR pin (pin 1) is 10K. Notice that during programming, voltage is 13V, thus current with 1K is very near to maximum rating value.

author: Etesla
author_rank: Regular Contributor
timestamp: September 17, 2017, 04:03:55 pm
content: SOLVEDThe issue was with my pickit 3/ MPlab IPE. The pickit was not pulling mclr high despite doing so for other microcontrollers, just not the 16f877a for whatever reason. "Manually" pulling mclr high solved the problem.Thank you all for your help!

author: StillTrying
author_rank: Super Contributor
timestamp: September 17, 2017, 04:17:24 pm
content: "Manually" pulling mclr high solved the problem.Is that a good or dangerous idea ?

author: sasa
author_rank: Regular Contributor
timestamp: September 17, 2017, 05:59:37 pm
content: Etesla,If you use ICSP, I hope you are aware of this app note (typical iCSP circuitry in order to isolate Vdd, i.e. 5V rail):http://ww1.microchip.com/downloads/en/DeviceDoc/31028a.pdfAs well as section 17.0, Absolute maximum ratings, Note 2 of your PIC datasheet:http://ww1.microchip.com/downloads/en/DeviceDoc/39582b.pdfOtherwise, possibility to fry MCU is quite high.

author: Etesla
author_rank: Regular Contributor
timestamp: September 17, 2017, 06:29:30 pm
content: I was using ICSP, but was removing the resistor that held mclr high and replacing it with the mclr pin from the pickit every time I programmed it, so no worries. Thanks for leading me to that app note! Ill be sure to keep it in mind.

author: Ian.M
author_rank: Super Contributor
timestamp: September 17, 2017, 06:51:56 pm
content: You don't have to remove the /MCLR pullup or use any special isolator circuit when programming a PIC as long as it is a simple pullup of 10K or greater and there is no capacitor on the /MCLR pin.Whether or not a Microchip programmer releases /MCLR after programming is dependent on a project specific setting for the programmer in the MPLAB IDE, or the setting 'Hold in reset'/'Release from reset' (toggle) in the IPE. Its possible that due to bugs in the driver in a particular MPLAB version, that this functionality may not work as expected, and you may have to disconnect the programmer pod from the target circuit.

author: Howardlong
author_rank: Super Contributor
timestamp: September 17, 2017, 08:54:48 pm
content: Quote from: Ian.M on September 17, 2017, 06:51:56 pmI'm in total agreement with this, a 10k pullup to Vdd and no cap is standard across the entire PIC range and all Microchip debuggers. If it doesn't work, there's something else afoot.FWIW, while there may be a legitimate and genuine reason for using the 16F877A, if it's a new project I'd strongly recommend going for one of the much more modern PIC16F1xxx or PIC16F1xxxx devices, they are better in pretty much every facet. The last project I did with a PIC16F877a was in 2003.

author: KL27x
author_rank: Super Contributor
timestamp: September 18, 2017, 05:13:29 am
content: QuoteThis doesn't sound likely to me (but I could be wrong). AFAIK, the PK can sink the MCLR line to ground, make it hiZ, or give it programming voltage of ~2.5 x max Vdd. I have never found an option to make it pull up MCLR to Vdd (in IPE), and it does not matter which microcontroller. Unless you're talking about pulling it up to programming voltage, manually?Most all PICs that were introduced from 1990's and beyond, including 877A, have an internal pullup on MCLR (which is often enabled by default when MCLR is enabled). Most all the ones from the last 10 or 20 years have selectable pullup when MCLR is disabled, too.

author: Ian.M
author_rank: Super Contributor
timestamp: September 18, 2017, 06:42:30 am
content: MPLAB 8 had an option to select between tristating /MCLR and driving it high on release from reset, and the programmer hardware could definitely drive it to Vdd as well as to Vpp, and also pull it down to 0V. However as all target boards are supposed to have either a /MCLR pullup, or have a circuit driving /MCLR, and driving it high was problematic on boards that had a simple reset button - resetting the target caused a programmer error - it makes sense that the option has been removed.

author: TomS_
author_rank: Frequent Contributor
timestamp: September 19, 2017, 08:47:32 pm
content: Quote from: sasa on September 17, 2017, 03:23:37 pmIf the PIC doesnt have LATx registers, implement your own using some bytes of memory. Its much safer than doing read-modify-write operations direct to PORTx registers.