Pic micro only working with PICKIT3 connected - Page 1
Forum section: electronics / general

author: old gregg
author_rank: Regular Contributor
timestamp: October 07, 2022, 01:47:01 pm
content: 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:// 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 ideathanks

author: JPortici
author_rank: Super Contributor
timestamp: October 07, 2022, 03:36:33 pm
content: Try with the button next to the green arrow (Make and program device main project)

author: hans
author_rank: Super Contributor
timestamp: October 07, 2022, 05:01:36 pm
content: 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.8VDo 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).

author: MikeK
author_rank: Super Contributor
timestamp: October 07, 2022, 05:17:22 pm
content: Do you have a pullup on MCLR? The PK3 might be providing that *requirement* when connected.

author: old gregg
author_rank: Regular Contributor
timestamp: October 08, 2022, 02:54:14 pm
content: Thanks for the answersQuoteyes I haveQuoteeverything is good on that side. It outputs the correct frequency.Quotei'm going to try that.QuoteThe 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

author: JPortici
author_rank: Super Contributor
timestamp: October 08, 2022, 03:51:53 pm
content: 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)

author: nigelwright7557
author_rank: Frequent Contributor
timestamp: October 08, 2022, 07:14:02 pm
content: Quote from: JPortici on October 07, 2022, 03:36:33 pmI had same problem and above fixed it for me.The PICKIT 3 was in debug mode and removing it from PIC stops the PIC.

author: JPortici
author_rank: Super Contributor
timestamp: October 08, 2022, 09:56:45 pm
content: Quote from: nigelwright7557 on October 08, 2022, 07:14:02 pmthat 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

author: TomS_
author_rank: Frequent Contributor
timestamp: October 13, 2022, 07:33:12 am
content: Quote from: nigelwright7557 on October 08, 2022, 07:14:02 pmIt'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.

author: old gregg
author_rank: Regular Contributor
timestamp: October 16, 2022, 11:00:18 am
content: Quotethat'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.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 16, 2022, 01:00:31 pm
content: 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.

author: TomS_
author_rank: Frequent Contributor
timestamp: October 18, 2022, 06:36:56 am
content: Quote from: old gregg on October 16, 2022, 11:00:18 amIt 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.