Connect with us

Seemingly unstable basic PIC18F2550 circuit

Discussion in 'Microcontrollers, Programming and IoT' started by crystal please, Jan 13, 2017.

Scroll to continue with content
  1. crystal please

    crystal please

    Jul 5, 2016
    From my work I've had quite a bit of experience with hardware development, but purely from a supervisory role, and so recently I've been playing around with ground up MCU circuit design to try to get a better understanding.

    I put the following circuit together to allow me to play around with the MCU registers a bit and it does work - only intermittently.

    The LED blinks as intended, then stops for an arbitrary time, flashes again a different number of times, off again etc. There doesn't seem to be any cyclic behaviour to it. It starts working without any external input (i.e. nudging it) so doesn't seem like a loose connection either. I realise the second Vss pin isn't grounded in the schematic, but this didn't help the circuit either when I tried it. Could it be because Vusb isn't grounded? I would have thought this would only affect USB operation.
    #include <stdio.h>
    #include <stdlib.h>
    #include <p18f2550.h>
    #include <delays.h>
    #pragma config FOSC = INTOSCIO_EC      
    #pragma config WDT = OFF              
    void main() {
        TRISAbits.TRISA1    = 0;    // Set RA1 as output
        LATAbits.LATA1      = 1;    // Set RA1 as HIGH
        while (1)
            LATAbits.LATA1 = ~LATAbits.LATA1;   // Toggle LED pin
            Delay10KTCYx(25);                   // Delay
    Here you can see the datasheet for the part.
  2. OBW0549


    Jul 5, 2016
    I don't know for a fact that these are causing your problem, but I suggest the following:

    You need to ground Vss pin 8. On PICs with multiple Vss/Vdd connections, ALL supply pins must be connected; you cannot leave them open.

    All unused I/O pins must either be set as outputs, or be connected to either Vss or Vdd. On power-up, I/O pins are configured as inputs by default, and if left floating can cause erratic behavior and/or excessive power consumption due to input stage shoot-through current. (The applies to all CMOS logic, by the way, not just microcontrollers. Don't leave inputs floating.)

    Assuming you are using the PIC's internal RC oscillator instead of a crystal, the OSC1/CLKI pin, pin 9, should be tied to either Vss or Vdd to keep it from floating (see above).
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day