User Tools

Site Tools


pic32mx270f256b

This is an old revision of the document!


Minimum setup for a PIC32MX270F256B on a Breadboard + PICkit3

My first experiments with PIC Microcontrollers was on the PIC32MX170F256B. But after discovering that there was no USB module on that controller, I then purchased a PIC32MX270F256B which did have one.

This article serves as a reminder for the minimum setup for this microcontroller.

Wiring up to the breadboard

First, take a look at the Datasheet for the PIC32MX270F256B.

Here is the overall layout on the breadboard:

Note the following pins on the Microcontroller:

  • Pin 1 is MCLR, and connects to Pin 1 on PICkit3.
  • Pins 13 (VDD), 23 (VBUS3V3) and 28 (AVDD) all connect to the Power Rail of the breadboard, and to Pin 2 (VDD) of the PICkit3.
  • Pins 8 (VSS), 19 (VSS) and 27 (AVSS) all connect to Ground, and to Pin 3 of the PICkit3.
  • Pin 4 (PGED1) connects to Pin 4 (PGD) of the PICkit3.
  • Pin 5 (PGEC1) connects to Pin 5 (PGC) of the PICkit3.
  • Pin 6 of the PICkit3 remains unconnected.

Next, a couple of LEDs for later testing:

  • Pin 2 (RA0) to the positive side of an LED. Negative side of the LED to a 10 Ohm resistor. Then to GND.
  • Pin 3 (RA1) to the positive side of an LED. Negative side of the LED to a 10 Ohm resistor. Then to GND.

On both the Power and Ground rails on the breadboard, add a 0.1uf capacitor each.

Also between Pin 20 (CAP) and Pin 9 (VSS) add a 0.01uf capacitor.

Add a 10k pull up resistor from Pin 1 (MCLR) to Power. MCLR is Master Clear or Reset.

That should be the minimum required to test the microcontroller.

You can also get a diagram of the recommended setup on page 28 of the PIC32MX270F256B Datasheet, Figure 2-1.

Sensing the chip and programming

Attach a USB cable between the PICkit3 and the computer's USB port.

  1. Load MPLABX IPE and go to Advanced Settings.
  2. Choose Family: 32-bit MCUs
  3. Choose Device: PIC32MX270F256B
  4. Under Power: Ensure 3.3V is chosen.
  5. ICSP Options: Check the “Power Target Circuit from Tool”
  6. Back in Operate, click on Read to see if PICkit3 can find the microcontroller.

The Output should result in:

Programmer to target power is enabled - VDD = 3.300000 volts.
Target device PIC32MX270F256B found.

A simple first test is to light an LED from RA1 which is pin 3 on the microcontroller.

In the MPLABX IDE, create a new C project and in the main.c file, add the following before the while loop:

TRISA = 0b00000000; //all PortA pins are output
PORTA = 0b00000010; //set pin 3 (RA1) to on. (supply 3.3 volts)
 
while(1)
{
}

A nice simple test. TRISA means all the A pins (RA0, RA1, RA2 etc). Setting each bit to 0 in this way means that every pin will be set as an output pin. This means that voltage can be output from the pin to power something.

PORTA is the way of turning on or off that voltage. So in the above code, only pin 3 (RA1) will be supplied with 3.3 volts. All the other pins will be 0 volts.

As we did earlier on the breadboard, you have a wire from RA1, to a 100Ohm resistor, to an LED and then to ground.

Compile the code. A hex file will be created at:

project\dist\PIC32MX270F256B-cpp\production\myfile.hex

Switch back to the MPLABX IPE and browse for your hex file. Program it to the chip by clicking the Program button.

The LED should light up. Good stuff. Your development flow is complete.

Programming two blinking LEDs

To blink back and forth between the two leds, change the code to:

    TRISA = 0b00000000; //all PortA pins are output
    PORTA = 0b00000010; //set pin 3 (RA1) to on. (supply 3.3 volts)
 
    int count = 0;
 
    while(1)
    {
        if (count >= 500000){
            mPORTAToggleBits(BIT_0);
            mPORTAToggleBits(BIT_1);
            count = 0;
        }
 
        count++;
    }

What happens if?

The following shows what happens, or what could happen if part of the minimum set up is not complete. This is only what I have noticed, the effects could be greater for others.

Component During Programming For Execution
Not using a pull up on MCLR to Positive No effects Could cause random resets on the PIC if the pin is floating.
No 0.1uf bypass capacitors Unstable effects No noticeable effect on basic test
No External Oscillator Not required Internal can be used
No AVDD on Pin 28PIC can't be found?
No AVSS on Pin 27PIC can't be foundExecutes normally
No Cap between VCAP on 20 to 21 to GND ?Executes normally
No VDD on Pin 13 ? Executes normally
No VSS on Pin 8 ? Executes normally
No PGEC1 connected Cannot connect to target device ?
No PGED1 connected Cannot connect to target device ?
pic32mx270f256b.1559116465.txt.gz · Last modified: 2021/02/02 01:24 (external edit)