Thursday, 23 August 2018

microcontroller - Seemingly unstable basic PIC18F2550 circuit


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.


Schematic



Code:


#include 
#include

#include
#include

#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 is the datasheet for the part.



Answer



Two things:



  1. One Vss pin is not connected. All Vss, Vdd, AVss, and AVdd pins, when present, must be properly connected.

  2. PGM is floating, which is bad if LVP is enabled. That can randomly put the part in programming mode.



No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...