Author Topic: 16f877a issues  (Read 3397 times)

0 Members and 1 Guest are viewing this topic.

Offline EteslaTopic starter

  • Regular Contributor
  • *
  • Posts: 149
  • Country: us
16f877a issues
« on: September 16, 2017, 11:49:21 pm »
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!
 

Offline woody

  • Frequent Contributor
  • **
  • Posts: 291
  • Country: nl
Re: 16f877a issues
« Reply #1 on: September 17, 2017, 09:51:50 am »
Try enabling the Power Up timer (PUT).

Paul

 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: 16f877a issues
« Reply #2 on: September 17, 2017, 02:50:34 pm »
Is the uP actually powered, and the power 100nF decoupled.
.  That took much longer than I thought it would.
 

Offline ggchab

  • Frequent Contributor
  • **
  • Posts: 276
  • Country: be
Re: 16f877a issues
« Reply #3 on: September 17, 2017, 02:57:55 pm »
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.
 

Offline sasa

  • Regular Contributor
  • *
  • !
  • Posts: 168
  • Country: 00
  • Hobbyist in electronic
Re: 16f877a issues
« Reply #4 on: September 17, 2017, 03:23:37 pm »
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.

As 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.
The 30+ years professional desktop software designer and software engineer
 

Offline EteslaTopic starter

  • Regular Contributor
  • *
  • Posts: 149
  • Country: us
Re: 16f877a issues
« Reply #5 on: September 17, 2017, 04:03:55 pm »
SOLVED

The 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!
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: 16f877a issues
« Reply #6 on: September 17, 2017, 04:17:24 pm »
"Manually" pulling mclr high solved the problem.

Is that a good or dangerous idea ?
.  That took much longer than I thought it would.
 

Offline sasa

  • Regular Contributor
  • *
  • !
  • Posts: 168
  • Country: 00
  • Hobbyist in electronic
Re: 16f877a issues
« Reply #7 on: September 17, 2017, 05:59:37 pm »
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.pdf

As well as section 17.0, Absolute maximum ratings, Note 2 of your PIC datasheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/39582b.pdf

Otherwise, possibility to fry MCU is quite high.
« Last Edit: September 17, 2017, 06:07:29 pm by sasa »
The 30+ years professional desktop software designer and software engineer
 
The following users thanked this post: Etesla

Offline EteslaTopic starter

  • Regular Contributor
  • *
  • Posts: 149
  • Country: us
Re: 16f877a issues
« Reply #8 on: September 17, 2017, 06:29:30 pm »
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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: 16f877a issues
« Reply #9 on: September 17, 2017, 06:51:56 pm »
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.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5317
  • Country: gb
Re: 16f877a issues
« Reply #10 on: September 17, 2017, 08:54:48 pm »
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.


I'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.
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: 16f877a issues
« Reply #11 on: September 18, 2017, 05:13:29 am »
Quote
The 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.
This 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.
« Last Edit: September 18, 2017, 05:18:21 am by KL27x »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: 16f877a issues
« Reply #12 on: September 18, 2017, 06:42:30 am »
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.
 

Offline TomS_

  • Frequent Contributor
  • **
  • Posts: 834
  • Country: gb
Re: 16f877a issues
« Reply #13 on: September 19, 2017, 08:47:32 pm »
IIRC, LAT is not present in PIC16 MCUs.

If 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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf