Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm build a circuit with a pic18F4550, I'm trying to power up 8 leds, but I get no output voltage from any output pin.

I suspect the pic might be broken because while building the circuit I made two mistakes: - I wired the 5v regulator wrongly, and supplied 9v to the pic for the first time - on one side of the pic I connected power to vss and ground to vcc

However, after noticing my mistakes and fixing them, I reprogrammed pic and got no error (I'm using MPlabX and PicKit2). Also the pic is not heating up or anything like that.

I triple checked all the wires and schematics, but there is only 5v in the two vcc pins, and 0v in the output ports.

This is my program:

#pragma config XINST = OFF
#if defined(__XC)
    #include <xc.h>        /* XC8 General Include File */
#elif defined(HI_TECH_C)
    #include <htc.h>       /* HiTech General Include File */
#elif defined(__18CXX)
    #include <p18cxxx.h>   /* C18 General Include File */
#if defined(__XC) || defined(HI_TECH_C)

#include <stdint.h>        /* For uint8_t definition */
#include <stdbool.h>       /* For true/false definition */

#define NO_CLRWDT
#define SYSCLK          20000000
#define PLL             4
#define SYSCLK_PLL      (SYSCLK*PLL)
#define FCY             (SYSCLK_PLL/2)

#include "system.h"        /* System funct/params, like osc/peripheral config */
#include "user.h"          /* User funct/params, such as InitApp */

void main(void){
    TRISD = 0x00;
    TRISC = 0x00;
    PORTC = 0xFF;
    PORTD = 0xFF;


Could my pic be broken? and how can I check or debug the issue? I'm newbie at both soft and electronics.

share|improve this question
the content of both ConfigureOscillator and InitApp "might" be useful. – Vladimir Cravero Jun 2 '14 at 15:30
Try to see if your software tools have a "verify" command. This verifies your program made it onto the microcontroller. Sometimes this is not checked for speed reasons. – HL-SDK Jun 2 '14 at 15:32
They are empty function, they are added by mplabx by deafault but I didn't add anything to them, I will delete them from the post so you don't get confused – Alexandru Severin Jun 2 '14 at 15:33
You may try sending 1's out to LAT*. From page 111 of the documentation it's supposed to be the other controlling knob on the IO pins: ww1.microchip.com/downloads/en/devicedoc/39632c.pdf PORT* should work, but I'd say messing with LAT* would be a last ditch effort. – horta Jun 2 '14 at 15:52
I'll bet it has to do with the Configuration Bits. For example, the Watchdog Timer is active by default and I don't see it disabled in your code. – m.Alin Jun 2 '14 at 16:24
up vote 8 down vote accepted

From my extensive experience of screw-ups and facepalms when building up circuits for PICs, if the chip still programs and verifies successfully, you're probably ok.

The problem you're having is in your code. Here's a list of probable causes:

  1. You don't have configuration bits set, so the FOSC bits are running as default. The default FOSC on an 18F4550 is an external clock. Unless you actually have an external clock connected to OSC1 (which you probably don't), your program won't execute.

  2. The watchdog timer is default to on, which means it's running and constantly resetting your chip. It should be disabled in the configuration bits.

  3. You have no infinite loop at the end of your code. Without an infinite loop, the program will reach the end of the program space and reset the chip. You can do something as simple as putting "while(1);" as the last line in your main function.

share|improve this answer
I have while(1), I just didn't add it post as it is empty. I will edit the post and add the entire program. – Alexandru Severin Jun 2 '14 at 16:15
+1 "From my extensive experience of screw-ups and facepalms when building up circuits for PICs, if the chip still programs and verifies successfully, you're probably ok. The problem you're having is in your code." I second that. I suspect the WDT is the culprit. – m.Alin Jun 2 '14 at 16:27

From the Absolute Maximums on the datasheet:

Voltage on any pin with respect to VSS (except VDD and MCLR)... -0.3V to (VDD + 0.3V)

Voltage on VDD with respect to VSS .......................... -0.3V to +7.5V

So, yes, by putting -9V on Vcc you have exceeded that range, and the manufacturer no longer guarantees the chip will work. Even if you had the polarity correct, you still exceed the range. That doesn't mean it's broken, necessarily, but errors can crop up in funny ways, and lifetime can be reduced.

If it were me, and I were about to put significant time and effort into this development, and if failures down the road would be inconvenient, I would change the chip. If it currently "worked" I would probably continue development, and swap when the new chips arrived.

Try not to order a count of just one of any part. It's cheaper, in the long run, to buy a few when you consider time and shipping costs.

share|improve this answer
I know I exceeded the required range, and I know I should have bought more, but sadly now I'm short of time and money, so I would like to be sure if it is broken before ordering another one. – Alexandru Severin Jun 2 '14 at 15:45
Always buy at least three if you are at all concerned about schedule. One to ruin, and one to have as a spare after you ruin one. – Spehro Pefhany Jun 2 '14 at 21:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.