help - PIC32MX adding XTAL drops voltage? - Page 1
Forum section: electronics / general

author: Circuitous
author_rank: Unknown
timestamp: July 11, 2013, 12:29:20 pm
content: I have a PIC32MX250F128D on a breakout and breadboard. It's running fine on the internal oscillator, but I need to use crystal to get the stability required to support USB MSD.So, I plugged in an 8Mhz XTAL and added the recommended 18pf caps to ground.The PIC runs, but the Vdd drops from 3.3 to 2.1V and current draw increases from 9ma to 12 ma, I don't get it. If I unplug the crystal (leaving the caps), then it runs fine.I have tried a couple of osc settings, ES and HS, neither seems to make any difference.here's a sample of the settings:Code:#pragma config FPLLMUL = MUL_24, FPLLIDIV = DIV_2, FPLLODIV = DIV_2, FWDTEN = OFF#pragma config POSCMOD = HS, FNOSC = PRIPLL, FPBDIV = DIV_1Why does adding the XTAL kill the supply rail?I'm probably making a basic mistake, as this is the first time I've used an external crystal on a PIC.

author: Skimask
author_rank: Super Contributor
timestamp: July 11, 2013, 01:31:38 pm
content: What's your power source?

author: Circuitous
author_rank: Unknown
timestamp: July 11, 2013, 02:39:52 pm
content: bench supply set to 3.3v. Originally I had the current limit at 20ma, so I increased it 10ma at a time up to 50 ma. But, no matter what, the circuit draws 12ma with the crystal, and no over current warnings.After reading a bit about connecting crystals to PICs, I'm wondering if it has too much gain... maybe I will have to insert a resistor, like in app ot AN849http://ww1.microchip.com/downloads/en/AppNotes/00849a.pdfI'll try that this evening.

author: andersm
author_rank: Super Contributor
timestamp: July 11, 2013, 04:33:27 pm
content: For crystals below 10MHz, the POSCMOD setting should be XT (though it probably won't affect the problem you're seeing).

author: nessatse
author_rank: Regular Contributor
timestamp: July 11, 2013, 05:32:08 pm
content: The question is why does your supply voltage drop when you are running under the current limit? Do you have decoupling caps on your supply rail? Have you looked at your supply on a scope?

author: PA0PBZ
author_rank: Super Contributor
timestamp: July 11, 2013, 07:57:06 pm
content: Exactly, if your VDD drops from 3.3 to 2.1 volts with a current draw of 12 mA there is something else to be concerned about apart from the PIC...

author: Circuitous
author_rank: Unknown
timestamp: July 11, 2013, 08:01:42 pm
content: Agreed. I'm wondering if it's creating noise and confusing the PSU?I'll do some more tests when I get home this evening.Thanks for the responses.

author: caroper
author_rank: Regular Contributor
timestamp: July 11, 2013, 08:27:10 pm
content: This is how I have mine set up on the Breadboard and it runs fine. I have not measured the current but the voltage is spot on 3V3.With FPLLMUL = MUL_24 you may be over clocking it tryFPLLMUL = MUL_20Config Bits are://* Oscillator Settings#pragma config FNOSC = PRIPLL // Oscillator selection#pragma config POSCMOD = XT // Primary oscillator mode#pragma config FPLLIDIV = DIV_2 // PLL input divider#pragma config FPLLMUL = MUL_20 // PLL multiplier#pragma config FPLLODIV = DIV_2 // PLL output divider#pragma config FPBDIV = DIV_1 // Peripheral bus clock divider#pragma config FSOSCEN = OFF // Secondary oscillator enable//* Clock control settings#pragma config IESO = OFF // Internal/external clock switchover#pragma config FCKSM = CSECME // Clock switching (CSx)/Clock monitor (CMx)#pragma config OSCIOFNC = OFF // Clock output on OSCO pin enable//* USB Settings#pragma config UPLLEN = ON // USB PLL enable#pragma config UPLLIDIV = DIV_2 // USB PLL input divider#pragma config FUSBIDIO = OFF // USB USID pin controlled by port function#pragma config FVBUSONIO = OFF // USB VBUSON pin controlled by port function//* Other Peripheral Device settings#pragma config FWDTEN = OFF // Watchdog timer enable#pragma config WDTPS = PS1024 // Watchdog timer postscaler#pragma config WINDIS = OFF#pragma config JTAGEN = OFF // JTAG port disabled//* Code Protection settings#pragma config CP = OFF // Code protection#pragma config BWP = OFF // Boot flash write protect#pragma config PWP = OFF // Program flash write protect//* Debug settings#pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select//#pragma config DEBUG = ON // DO NOT SET THIS CONFIG BIT, it will break debugging#pragma config PMDL1WAY = OFF // Allow multiple reconfigurations#pragma config IOL1WAY = OFF // Allow multiple reconfigurationsCheersChrishttp://caroper.blogspot.com/

author: Circuitous
author_rank: Unknown
timestamp: July 11, 2013, 08:41:41 pm
content: Chris, thanks!BTW, I liked your tutorials on the 250F128B, any your bog posts. I read through those over the weekend. It was very helpful in navigating my way through issues with the 128d.I have a couple of 128b chips, I may go to a plain breadboard and try your setup with one of those.

author: David_AVD
author_rank: Super Contributor
timestamp: July 11, 2013, 09:52:14 pm
content: Also make sure you connect all Vcc and Vss pins, not just some of them.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: July 11, 2013, 10:32:08 pm
content: QuoteQuoteThese two statements do not make sense. Either it is drawing 12mA at 3.3v, or the voltage at the PIC pins is drooping when it draws more current due to the PSU or connections.It is reasonable to assume that current draw may increase slightly with a crystal.There is something wrong with your power supply arrangement

author: Circuitous
author_rank: Unknown
timestamp: July 11, 2013, 11:35:39 pm
content: Let's go back to my original statement "...probably making a basic mistake". Yep, a couple of them.I just got back to the bench...Yes, not going into current limit threw me. But, it actually is.Last night I just didn't notice the little "CV" text changed to "CC" on the PSU display. Other PSUs usually make it fairly obvious that it's gone into CC mode. So, maybe a point for those against the Rigol products (DP1308A).I changed it toPOSCMOD = XTand that fixed it. That jumps the power consumption up to just over 30ma, a lot more than I was expecting.basic mistakes:PSU problem: meXtal problem: misread datasheet rangesAgain, thanks for the guidance, and patience.

author: WarSim
author_rank: Frequent Contributor
timestamp: July 12, 2013, 12:40:14 am
content: I believe you neglected to add the bread board capacitance in your capacitor calculations.

author: Circuitous
author_rank: Unknown
timestamp: July 12, 2013, 01:24:54 am
content: I considered the capacitance, but I have seen other breadboarded XTAL setups for microcontrollers that used the recommended caps. I had tried it last night with smaller caps, down to 5pf, but no difference.The key was the POSCMOD = XT setting, ES didn't provide enough gain and HS was too much.My breadboards are all attached to aluminium base plates. I was thinking about making some capacitance measurements, might do that soon.

author: WarSim
author_rank: Frequent Contributor
timestamp: July 12, 2013, 06:56:44 am
content: Not all the capacitance is series capacitance.Some times I have had to put crystals on modified dip-clips.Some I had to lift the legs out of the bread board and use a modified dip-clip.But yes it is odd that the type of crystal you are using at only 8MHz is having this much trouble.Have you tried shifting the project down board, maybe you can find a better set of contacts.Most people reuse breadboards and after a while the boards become unusable.Hopefully you didn't s up with a clone or something.

author: caroper
author_rank: Regular Contributor
timestamp: July 12, 2013, 08:42:51 pm
content: Quote from: WarSim on July 12, 2013, 12:40:14 amAs an aside, I actually pulled out the two 22nf caps on my Breadboard and it continued to oscillate quite happily just on the breadboard capacitance alone, not that I would recommend it as a standard practice.@Circuitus - Thanks for the kind wordsI have made two further posts this week, looking at the DP32 in practice and setting it up for further experiments. The posts also contain a 2 part dissertation of why I think the Arduino Environment is good for PIC32MX development. Not sure that everyone would agree, but then they are free to stumble on with MPLABX and a crippled compilerand I also added a new header and a botch wire to to the DP32 to fix the ICSP header design flaw.CheersChrishttp://caroper.blogspot.com/p.s. I finally got round to measuring the current consumption on the DP32 board, which is similar to my Breadboard layout, and it is 26mA at 3V3. That is feeding it via the PICKit 3, so it bypasses any losses in the voltage regulator.

author: OZ1LQB
author_rank: Regular Contributor
timestamp: July 14, 2013, 11:39:07 am
content: Hi..the 2 caps you removed should be 22pf not 22nfi hope it was a typing error if not try 22pfClaus

author: caroper
author_rank: Regular Contributor
timestamp: July 16, 2013, 01:27:46 pm
content: Typing Error