0
\$\begingroup\$

Recently I built my own PIC32MX274F256D development board where I want to experiment.

My problem is that the board cannot be programmed. I tried ICD3 and PickIt3 with MPLAB X IDE and IPE.

The dev board uses a 16MHz crystal with 18pF caps as primary osc and a 32.768KHz with 12pF caps, as a secondary osc for the RTC

These are my configuration bits:

I tried to power the MCU from the programmer ICD3/PickIt3 and also from external 3.3v power supply

I tried to program the MCU through PGC1/2/3/4. Nothing!

I changed the configuration bits. Nothing!

I checked the board for short circuits wrong connections etc. Nothing!

When I try to program the MCU through IPE I can successfully erase the MCU, and perform a blank check.

Also I let the tool to choose the memory ranges. Nothing!

When I try to verify after erase it produces the following message:

Erasing...
Erase successful

Verifying...
The following memory areas(s) will be verified:

program memory: start address = 0x1d000000, end address = 0x1d03ffff
boot config memory
configuration memory
boot config memory
Address: 1fc00000 Expected Value: ffffffff Received Value: ff00002
program memory
Address: 1d000000 Expected Value: ffffffff Received Value: 27bdffa8

Verify failed 

When I perform an erase action and then I try to program the MCU I receive the following message:

Erasing...
Erase successful

2018-08-26 13:25:47 +0300 - Hex file loaded successfully.
Loading code from C:\Users\me\Desktop\MPLAB PDN\projects\projects\PIC32_My_General_Examples\devBoard\devBoard.X\dist\default\production\devBoard.X.production.hex...
2018-08-26 13:26:04 +0300 - Programming...
Device Erased...

Programming...
The following memory area(s) will be programmed:
program memory: start address = 0x1d000000, end address = 0x1d0007ff
boot config memory
configuration memory
boot config memory
Address: 1fc0001c Expected Value: 275a0270 Received Value: 275a0010
Failed to program device

I don't know what I am doing wrong here.

I also replaced the MCU with a new one. NOTHING!

Next I present the test program that I try to send to the MCU to see if it can be programmed.

#include <stdio.h>
#include <stdlib.h>
#include <xc.h>

// DEVCFG3
// USERID = No Setting
#pragma config AI2C1 = ON // Alternate I/O Select for I2C1 (I2C1 uses the ASDA1/ASCL1 pins)
#pragma config AI2C2 = ON // Alternate I/O Select for I2C2 (I2C2 uses the ASDA2/ASCL2 pins)
#pragma config PMDL1WAY = ON // Peripheral Module Disable Configuration (Allow only one reconfiguration)
#pragma config IOL1WAY = ON // Peripheral Pin Select Configuration (Allow only one reconfiguration)
#pragma config FUSBIDIO = ON // USB USID Selection (Controlled by the USB Module)

// DEVCFG2
#pragma config FPLLIDIV = DIV_4 // PLL Input Divider (4x Divider)
#pragma config FPLLMUL = MUL_24 // PLL Multiplier (24x Multiplier)
#pragma config FPLLICLK = PLL_POSC // System PLL Input Clock Selection (POSC is input to the System PLL)
#pragma config UPLLIDIV = DIV_4 // USB PLL Input Divider (4x Divider)
#pragma config UPLLEN = ON // USB PLL Enable (USB PLL Enabled)
#pragma config FPLLODIV = DIV_2 // System PLL Output Clock Divider (PLL Divide by 2)
#pragma config BOREN = ON // Brown-Out Reset (BOR) Enable (Enable BOR)
#pragma config DSBOREN = ON // Deep Sleep BOR Enable (Enable ZPBOR during Deep Sleep Mode)
#pragma config DSWDTPS = DSPS32 // Deep Sleep Watchdog Timer Postscaler (1:2^36)
#pragma config DSWDTOSC = LPRC // Deep Sleep WDT Reference Clock Selection (Select LPRC as DSWDT Reference clock)
#pragma config DSWDTEN = ON // Deep Sleep Watchdog Timer Enable (Enable DSWDT during Deep Sleep Mode)
#pragma config FDSEN = ON // Deep Sleep Enable (Enable DSEN bit in DSCON)

// DEVCFG1
#pragma config FNOSC = SPLL // Oscillator Selection Bits (System PLL)
#pragma config FSOSCEN = ON // Secondary Oscillator Enable (Enabled)
#pragma config IESO = ON // Internal/External Switch Over (Enabled)
#pragma config POSCMOD = HS // Primary Oscillator Configuration (HS osc mode)
#pragma config OSCIOFNC = OFF // CLKO Output Signal Active on the OSCO Pin (Disabled)
#pragma config FPBDIV = DIV_1 // Peripheral Clock Divisor (Pb_Clk is Sys_Clk/1)
#pragma config FCKSM = CSDCMD // Clock Switching and Monitor Selection (Clock Switch Disable, FSCM Disabled)
#pragma config WDTPS = PS1048576 // Watchdog Timer Postscaler (1:1048576)
#pragma config WDTSPGM = ON // Watchdog Timer Stop During Flash Programming (Watchdog Timer stops during Flash programming)
#pragma config WINDIS = OFF // Watchdog Timer Window Enable (Watchdog Timer is in Non-Window Mode)
#pragma config FWDTEN = OFF // Watchdog Timer Enable (WDT Disabled (SWDTEN Bit Controls))
#pragma config FWDTWINSZ = WINSZ_25 // Watchdog Timer Window Size (Window Size is 25%)

// DEVCFG0
#pragma config JTAGEN = OFF // JTAG Enable (JTAG Disabled)
#pragma config ICESEL = ICS_PGx3 // ICE/ICD Comm Channel Select (Communicate on PGEC1/PGED1)
#pragma config PWP = OFF // Program Flash Write Protect (Disable)
#pragma config SMCLR = MCLR_NORM // Soft Master Clear Enable (MCLR pin generates a normal system Reset)
#pragma config BWP = OFF // Boot Flash Write Protect bit (Protection Disabled)
#pragma config CP = OFF // Code Protect (Protection Disabled)

int main(void) {

    return (EXIT_SUCCESS);
}

I have also attached the schematic of the dev board I created,

in case you see something that I don't.

enter image description here

I think I have tried everything...Please Help!

Thank you in advance.

\$\endgroup\$
  • 3
    \$\begingroup\$ R11 is suspiciously low valued. MCLR is used by the programmer to supply the programming voltage, and they cannot supply much current, try something more like 10k or so. \$\endgroup\$ – Dan Mills Aug 26 '18 at 11:45
  • \$\begingroup\$ I noticed that MCLR pin stays at 0.02V all the time. I removed the connector from the board and measured MCLR on PICKITagain. It stays LOW. Shouldn't this be around 3.3v? I also desoldered C3 but since MCLR is always at 0v will not see any change I guess. \$\endgroup\$ – Lefteris Aug 26 '18 at 17:08
2
\$\begingroup\$

A few things to check from my personal experience. Instability and noise.

  1. Ensure that your programming cable is short and all the conductors reasonably close to equal length.
  2. Ensure that your crystals are rated to use the load capacitance that you have mounted (remember that the capacitors are essentially in series as far as the crystal in concerned so with the capacitors shown, its 9pF and 6pF loading).
  3. Ensure that your Vcap (C8) is ether a low esr tantalium or a good ceramic capacitor (very important for stable operation).
  4. Confirm the values that were installed for the Vcap and oscillator capacitors.

*Edit: The specification sheet also recommends isolating the MCLR capacitor during programming to avoid it's influence. If you can desolder R11 for your initial programming, it may improve programming.

\$\endgroup\$
  • \$\begingroup\$ I will try what you suggest and I will come back hopefully with good news... Thank you for the support guys \$\endgroup\$ – Lefteris Aug 26 '18 at 12:25
  • \$\begingroup\$ One quick notice though. In the MCU datasheet ( p.34) it is mentioned that these two exact values for R8 and R11 (10k and 1k respectively) should be used. And also when you say to desolder R11 you mean to leave it open? Why not to remove the MCLR cap (C3) instead? \$\endgroup\$ – Lefteris Aug 26 '18 at 12:46
  • \$\begingroup\$ @Lefteris It's a weird circuit for sure - sharing the reset pin with single-wire debugging sounds like a horrible idea. I'm no PIC expert, but my take from the datasheet is that the cap is only there to filter noise when the pin acts as reset. The 1k resistor is supposedly (according to the manual) protecting the pin from ESD, which is also weird, given that ESD will come from the connector, not from the cap. I really don't understand how the design makes any sense. Check if there is any errata regarding this! \$\endgroup\$ – Lundin Aug 27 '18 at 7:03
2
\$\begingroup\$

Problem Solved! Thank you guys!! I increased the R11 from 1k to 10k. Just That. So, why the datasheet says that R11 must me 1k? Can you explain it? I don't understand

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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