1
\$\begingroup\$

I have been working on a PIC24FJ128GA310 development board for for some time now and recently got a PCB made. If I try to move my code into the new board all timing related math and functions are failing on HS oscillator even the UART lines wont work at the desired baud rate. The device does not run when I put it to XT oscillator.

After some debugging, I found out that the PLL module wasn't getting locked. I have a 8 MHz oscillator with PRIPLL config bit on. So, instead of having FCY of ((8*4)/2) I have (8/2). The case is true if I have POSCMD as HS. But if I put POSCMD as XT, the controller just wont work at all. I am unable to debug the code with POSCMD as XT, IDE says device is not ready for debugging as some config bit is incorrect or the emulator is not wired properly. I know for sure the pickit3 connections are fine because when I change the POSCMD to HS or put the device to work on internal oscillator I am able to get into debug mode.

I tried doing a while(OSCCONbits.LOCK == 0); at the starting to check if the PLL module start-up timer is satisfied. But it never out of that loop. I also tried to start up with internal oscillator and then switch to external oscillator and PLL without much luck.

After some research online I got to this thread, which says the capacitor on Vcore pin should be causing the problem. I changed that capacitor to a through hole 10uF tantalum. But still the issue remains unresolved.

Here is the schematic and layout of relevant sections.

Oscillator Circuit Oscillator Circuit

Vcore pin Vcore pin

Layout of both. Bottom Layer Layout for both. Bottom Layer

I have run out of options and need some help. Please suggest any other course of action. Thanks for any help.

\$\endgroup\$
  • \$\begingroup\$ It may be something to do with your crystal setup. Please post schematic and board layout for that portion. \$\endgroup\$ – Majenko Dec 15 '14 at 12:32
  • \$\begingroup\$ @Majenko I have added the schematic and layout for the relevant sections. Please have a look. \$\endgroup\$ – Siddharth Dec 15 '14 at 13:30
  • 1
    \$\begingroup\$ What is the "load capacitance" of your 8MHz crystal? C35 and C38 look suspect to me. \$\endgroup\$ – Majenko Dec 15 '14 at 13:54
  • \$\begingroup\$ @Majenko I am using digikey.com/product-detail/en/ABM3B-8.000MHZ-B2-T/535-9720-1-ND/… this part. The load capacitance is 18pF. \$\endgroup\$ – Siddharth Dec 15 '14 at 16:46
1
\$\begingroup\$

Firstly the Vcore capacitor - Microchip recommends a low-ESR (such as ceramic) 10uF cap there. Your 10uF tantalum in parallel with the 100nF ceramic will probably work though, so I don't think this is your problem.

As for you oscillator config - for an 8MHz crystal you really should have the POSCMD bits set for XT mode (01) as HS mode is intended to be used with crystals 10MHz and higher. Using an 8MHz crystal in HS mode could make the oscillator too unstable for the PLL to lock.
Check the recommended load capacitance for your specific crystal and if its manufacturer recomends any other 'extra' components (I have on occasion needed to add a large resistor in parallel to achieve reliable oscillation), but I suspect that the capacitance is your most likely problem.
Remember that an xxpF capacitance spec on the crystal datasheet does NOT mean 'use a pair of xxpF capacitors' ... I struggled with this fun fact about crystals for far too long before finally figuring it out.

\$\endgroup\$
  • \$\begingroup\$ I am using digikey.com/product-detail/en/ABM3B-8.000MHZ-B2-T/535-9720-1-ND/… this part. The load capacitance is 18pF. \$\endgroup\$ – Siddharth Dec 15 '14 at 16:43
  • \$\begingroup\$ if I make the POSCMD as XT, the system wont even start up. I cannot debug in this oscillator mode, so I have no clue of what is actually happening. \$\endgroup\$ – Siddharth Dec 15 '14 at 16:45
  • 1
    \$\begingroup\$ The load capacitance which your crystal 'sees' is not the value of each of the capacitors you've got connected to it. Its the series combination of them + the parasitics of your pcb, etc. So in your case you're probably not getting much more than 10-12pF - not the 18pF listed on the datasheet. I'd recommend replacing those 18pF caps of yours with 33pF. \$\endgroup\$ – brhans Dec 15 '14 at 16:49
  • \$\begingroup\$ You could also try using a slightly larger cap on the OSC2 pin vs the one on OSC1 as this apparently creates more of a phase shift on power-up which can aid oscillator start-up. \$\endgroup\$ – brhans Dec 15 '14 at 16:56
  • \$\begingroup\$ Thanks a lot. I will make that change to the board and check if there are any improvements. \$\endgroup\$ – Siddharth Dec 15 '14 at 17:53

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.