Author Topic: Pic micro only working with PICKIT3 connected  (Read 1859 times)

0 Members and 1 Guest are viewing this topic.

Offline old greggTopic starter

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Pic micro only working with PICKIT3 connected
« on: October 07, 2022, 01:47:01 pm »
Hi,
I've a very strange thing going on. The pic microcontroller I'm using (PIC24EP32GP204) only works when the Pickit3 is connected. If I turn OFF the power supply, remove the pickit3, turn the supply on again,  nothing happens.

I'm just toogling a pin and outputing the clock to a pin. Everything seems correct, I pulled the MCLR pin high via a 10K resistor, Vcap is a 10uF cap. Regarding MPLABX, I read about building the program for "release mode" but It seems it already does it when using the "run project" button (the green triangle in the menu bar). I even changed the PIC without success.

I did some research and found nothing.

Here is the config :
Code: [Select]
// FICD
#pragma config ICS = PGD3               // ICD Communication Channel Select bits (Communicate on PGEC3 and PGED3)
#pragma config JTAGEN = OFF             // JTAG Enable bit (JTAG is disabled)

// FPOR
#pragma config ALTI2C1 = OFF            // Alternate I2C1 pins (I2C1 mapped to SDA1/SCL1 pins)
#pragma config ALTI2C2 = OFF            // Alternate I2C2 pins (I2C2 mapped to SDA2/SCL2 pins)
#pragma config WDTWIN = WIN25           // Watchdog Window Select bits (WDT Window is 25% of WDT period)

// FWDT
#pragma config WDTPOST = PS32768        // Watchdog Timer Postscaler bits (1:32,768)
#pragma config WDTPRE = PR128           // Watchdog Timer Prescaler bit (1:128)
#pragma config PLLKEN = ON              // PLL Lock Enable bit (Clock switch to PLL source will wait until the PLL lock signal is valid.)
#pragma config WINDIS = OFF             // Watchdog Timer Window Enable bit (Watchdog Timer in Non-Window mode)
#pragma config FWDTEN = OFF         // Watchdog Timer Enable bit (Watchdog timer enabled/disabled by user software)

// FOSC
#pragma config POSCMD = NONE            // Primary Oscillator Mode Select bits (Primary Oscillator disabled)
#pragma config OSCIOFNC = ON           // OSC2 Pin Function bit (OSC2 is clock output)
#pragma config IOL1WAY = ON             // Peripheral pin select configuration (Allow only one reconfiguration)
#pragma config FCKSM = CSDCMD           // Clock Switching Mode bits (Both Clock switching and Fail-safe Clock Monitor are disabled)

// FOSCSEL
#pragma config FNOSC = FRC              // Oscillator Source Selection (Internal Fast RC (FRC))
#pragma config IESO = ON                // Two-speed Oscillator Start-up Enable bit (Start up device with FRC, then switch to user-selected oscillator source)

// FGS
#pragma config GWRP = OFF               // General Segment Write-Protect bit (General Segment may be written)
#pragma config GCP = OFF                // General Segment Code-Protect bit (General Segment Code protect is Disabled)
 

if someone has an idea  :-//
thanks
« Last Edit: October 07, 2022, 01:56:28 pm by old gregg »
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: Pic micro only working with PICKIT3 connected
« Reply #1 on: October 07, 2022, 03:36:33 pm »
Try with the button next to the green arrow (Make and program device main project)
 

Offline hans

  • Super Contributor
  • ***
  • Posts: 1637
  • Country: nl
Re: Pic micro only working with PICKIT3 connected
« Reply #2 on: October 07, 2022, 05:01:36 pm »
Random remote troubleshooting idea's..

Don't use the debugger mode to program the PIC. There shuold be a compile+program button instead. In my experience debug builds have some flags set in the background so the PIC doesn't self-start (I suspect so that the debugger can "catch" the PIC's breakpoints in time e.g. before entering main)

Have you tried manually pulling MCLR to GND after power up? If the program magically works, that could indicate some power-on specific issue. If it still doesn't work, that indicates something is not set up properly (such as loading programs under debug mode)

What kind of capacitor are you using for Vcap? Datasheet asks for ESR <1Ohm, ceramic or tantal. I presume you checked all VDD/GND pairs are connected and decoupled. What voltage is on Vcap to GND? Typ should be 1.8V

Do you have a scope? What do you measure on OSC2? It should output the FRC clock with current fuse settings.

Very unlikely: try setting PLLKEN to OFF (in the odd chance that makes a difference, it shouldn't though).
 

Offline MikeK

  • Super Contributor
  • ***
  • Posts: 1314
  • Country: us
Re: Pic micro only working with PICKIT3 connected
« Reply #3 on: October 07, 2022, 05:17:22 pm »
Do you have a pullup on MCLR?  The PK3 might be providing that *requirement* when connected.
 

Offline old greggTopic starter

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: Pic micro only working with PICKIT3 connected
« Reply #4 on: October 08, 2022, 02:54:14 pm »
Thanks for the answers

Quote
Do you have a pullup on MCLR?  The PK3 might be providing that *requirement* when connected.
yes I have

Quote
Do you have a scope? What do you measure on OSC2? It should output the FRC clock with current fuse settings.
everything is good on that side. It outputs the correct frequency.
Quote
Have you tried manually pulling MCLR to GND after power up? If the program magically works, that could indicate some power-on specific issue. If it still doesn't work, that indicates something is not set up properly (such as loading programs under debug mode)

i'm going to try that.

Quote
What kind of capacitor are you using for Vcap? Datasheet asks for ESR <1Ohm, ceramic or tantal. I presume you checked all VDD/GND pairs are connected and decoupled. What voltage is on Vcap to GND? Typ should be 1.8V

The issue seems to be here. With the pickit3 connected the pin is at 1.8V, once removed and the power supply is turned on/off the pin goes to about 125mV.  I'm using a 10uF ceramic, try different value, no changes. The problem seems to be power related, if only Vdd and ground are connected to the pickit3, it starts normally.

I found this page : https://microchipsupport.force.com/s/article/PIC32-Device-not-starting-up

« Last Edit: October 08, 2022, 02:56:08 pm by old gregg »
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: Pic micro only working with PICKIT3 connected
« Reply #5 on: October 08, 2022, 03:51:53 pm »
Yes you are onto something..

is the circuit mounted on a solderless breadboard? there was a recent thread on the microchip forum and the OP had issues simillar to yours. rebuilding the circuit made the problem go away.
In short: Make sure all connections are good, Make connections as short as possible, possibly with pieces of wire cut to length instead of those long jumpers.
One decoupling capacitor per VDD pin and a 10u capacitor on the VDD line to provide bulk capacitance.
And of course VCAP. 10u ceramic as you did is fine.
Resistor from VDD to MCLR and a capacitor from MCLR to VSS (10k/100n combo is fine)
 

Offline nigelwright7557

  • Frequent Contributor
  • **
  • Posts: 689
  • Country: gb
    • Electronic controls
Re: Pic micro only working with PICKIT3 connected
« Reply #6 on: October 08, 2022, 07:14:02 pm »
Try with the button next to the green arrow (Make and program device main project)
I had same problem and above fixed it for me.
The PICKIT 3 was in debug mode and removing it from PIC stops the PIC.

 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: Pic micro only working with PICKIT3 connected
« Reply #7 on: October 08, 2022, 09:56:45 pm »
Try with the button next to the green arrow (Make and program device main project)
I had same problem and above fixed it for me.
The PICKIT 3 was in debug mode and removing it from PIC stops the PIC.

that was my first guess, but it would not be consistent with VCAP going to zero when the pickit is disconnected. could be an issue with grounding or power supply, with the construction of the circuit
 

Offline TomS_

  • Frequent Contributor
  • **
  • Posts: 834
  • Country: gb
Re: Pic micro only working with PICKIT3 connected
« Reply #8 on: October 13, 2022, 07:33:12 am »
The PICKIT 3 was in debug mode and removing it from PIC stops the PIC.
It's not the PICKIT that is in debug mode, it's the PIC itself.

When you do a debug build, some additional code is included to enable it to work with the debugger.

When you do a production build that code is omitted and the PIC can run independently.
 

Offline old greggTopic starter

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: Pic micro only working with PICKIT3 connected
« Reply #9 on: October 16, 2022, 11:00:18 am »
Quote
When you do a debug build, some additional code is included to enable it to work with the debugger.

that's what I understood. But I can't find out how to enable or disable this features if MPlabx doesn't do it iteself.

However I did a bit of soldering and cleaning, the issue is gone ! I've 1.8V at the cap in all situation. The only component I have not put back it's the bulk capacitor after the output of the 3.3V regulator.

I'll probably build a second pcb to see if the problem appears again.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5895
  • Country: es
Re: Pic micro only working with PICKIT3 connected
« Reply #10 on: October 16, 2022, 01:00:31 pm »
Ensure you're not:
- Building for debugging
- Programming for debugging
- Setting the config bit DEBUG=ON somewhere with a #pragma directive or in the Configuration Bits tab.

« Last Edit: October 16, 2022, 01:07:14 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline TomS_

  • Frequent Contributor
  • **
  • Posts: 834
  • Country: gb
Re: Pic micro only working with PICKIT3 connected
« Reply #11 on: October 18, 2022, 06:36:56 am »
that's what I understood. But I can't find out how to enable or disable this features if MPlabx doesn't do it iteself.
It will be inserted by "the compiler" because it is required during debugging. You'd "disable it" by performing a production build which generally does not support debugging.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf