Author Topic: PIC32 external osc not working  (Read 4588 times)

0 Members and 1 Guest are viewing this topic.

Offline mapexmbirchTopic starter

  • Contributor
  • Posts: 20
PIC32 external osc not working
« on: March 22, 2017, 04:54:54 pm »
Hi

I have a PIC32MZ1024EF064 with a 8MHz external resonator.

http://onecall.farnell.com/murata/cstce8m00g52a-r0/resonator-ceramic-8mhz-smd/dp/2443267?ost=CSTCE8M00G52A-R0&selectedCategoryId=&categoryNameResp=All&searchView=table&iscrfnonsku=false

I have used this resonator before on a PIC18 and PIC24, both worked fine.

I can get my code to work fine with the internal FRC (8MHz), but when I switch it to the external osc, it doesn't start and it uses the other internal osc.

My setup code:
Code: [Select]
#pragma config FMIIEN = ON             // Ethernet RMII/MII Enable (MII Enabled)
#pragma config FETHIO = ON              // Ethernet I/O Pin Select (Default Ethernet I/O)
#pragma config PGL1WAY = ON            // Permission Group Lock One Way Configuration (Allow only one reconfiguration)
#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 = OFF           // USB USBID Selection (Controlled by the USB Module)

// DEVCFG2
#pragma config FPLLIDIV = DIV_1         // System PLL Input Divider (1x Divider)
#pragma config FPLLRNG = RANGE_5_10_MHZ // System PLL Input Range (8-16 MHz Input)
#pragma config FPLLICLK = PLL_POSC     // System PLL Input Clock Selection (POSC is input to the System PLL)
#pragma config FPLLMULT = MUL_45         // System FRC Multiplier (FRC Multiply by 45)
#pragma config FPLLODIV = DIV_2         // System PLL Output Clock Divider (2x Divider)
#pragma config UPLLFSEL = FREQ_12MHZ    // USB PLL Input Frequency Selection (USB PLL input is 12 MHz)

// DEVCFG1
#pragma config FNOSC = SPLL          // Oscillator Selection Bits (Primary Osc (HS,EC))
#pragma config DMTINTV = WIN_127_128    // DMT Count Window Interval (Window/Interval value is 127/128 counter value)
#pragma config FSOSCEN = OFF            // Secondary Oscillator Enable (Disable SOSC)
#pragma config IESO = OFF                // Internal/External Switch Over (Disabled)
#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 FCKSM = CSDCMD           // Clock Switching and Monitor Selection (Clock Switch Enabled, FSCM Enabled)
#pragma config WDTPS = PS1048576        // Watchdog Timer Postscaler (1:1048576)
#pragma config WDTSPGM = STOP           // Watchdog Timer Stop During Flash Programming (WDT stops during Flash programming)
#pragma config WINDIS = NORMAL          // Watchdog Timer Window Mode (Watchdog Timer is in non-Window mode)
#pragma config FWDTEN = OFF             // Watchdog Timer Enable (WDT Disabled)
#pragma config FWDTWINSZ = WINSZ_25     // Watchdog Timer Window Size (Window size is 25%)
#pragma config DMTCNT = DMT31           // Deadman Timer Count Selection (2^31 (2147483648))
#pragma config FDMTEN = OFF             // Deadman Timer Enable (Deadman Timer is disabled)

// DEVCFG0
#pragma config DEBUG = OFF              // Background Debugger Enable (Debugger is disabled)
#pragma config JTAGEN = OFF             // JTAG Enable (JTAG Disabled)
#pragma config ICESEL = ICS_PGx1        // ICE/ICD Comm Channel Select (Communicate on PGEC1/PGED1)
#pragma config TRCEN = ON               // Trace Enable (Trace features in the CPU are enabled)
#pragma config BOOTISA = MIPS32         // Boot ISA Selection (Boot code and Exception code is MIPS32)
#pragma config FECCCON = OFF_UNLOCKED   // Dynamic Flash ECC Configuration (ECC and Dynamic ECC are disabled (ECCCON bits are writable))
#pragma config FSLEEP = OFF             // Flash Sleep Mode (Flash is powered down when the device is in Sleep mode)
#pragma config DBGPER = PG_ALL          // Debug Mode CPU Access Permission (Allow CPU access to all permission regions)
#pragma config SMCLR = MCLR_NORM        // Soft Master Clear Enable bit (MCLR pin generates a normal system Reset)
#pragma config SOSCGAIN = GAIN_2X       // Secondary Oscillator Gain Control bits (2x gain setting)
#pragma config SOSCBOOST = OFF          // Secondary Oscillator Boost Kick Start Enable bit (Normal start of the oscillator)
#pragma config POSCGAIN = GAIN_2X       // Primary Oscillator Gain Control bits (2x gain setting)
#pragma config POSCBOOST = ON           // Primary Oscillator Boost Kick Start Enable bit (Boost the kick start of the oscillator)
#pragma config EJTAGBEN = NORMAL        // EJTAG Boot (Normal EJTAG functionality)


I have no idea what you should look for when selecting an resonator.

When I probe the pins there is about 0.5V of DC on one pin and 0V on the other.   A picture of how I connected it to the PIC is attached.

Any help would be greatly appreciated!
 

Offline Lunasix

  • Regular Contributor
  • *
  • Posts: 142
  • Country: fr
Re: PIC32 external osc not working
« Reply #1 on: March 22, 2017, 09:54:43 pm »
There is an errata for PIC32MZ and external resonator ! Verify your silicon revision.
I prefer an external oscillator, work always.
 

Offline rcbuck

  • Frequent Contributor
  • **
  • Posts: 346
  • Country: us
Re: PIC32 external osc not working
« Reply #2 on: March 23, 2017, 02:01:21 am »
I think you are referring to the PIC32MZ1024EFE064.

Errata for the part says this:
Revision  A1  Silicon: A  crystal  oscillator  cannot be  used  as  an  input  to  the  Primary  Oscillator (POSC) pins OSC1 and OSC2.

Revision A1 Silicon Work around
Use   an   external   clock   or   the   Internal   FRC

They are showing the same problem for Revision A2. Rev A3 doesn't appear to have the problem but does require a very specific oscillator circuit. See the errata sheet here:

http://ww1.microchip.com/downloads/en/DeviceDoc/80000663D.pdf
 

Offline mapexmbirchTopic starter

  • Contributor
  • Posts: 20
Re: PIC32 external osc not working
« Reply #3 on: March 23, 2017, 10:22:04 am »
Thanks for the replies guys.

I have replaced the resonator and applied a bit more solder to the pins,and still nothing.

I think I have revision E3.  That's what it says on the top, not sure if that is the revision number or not.  See attached.

I think I might use this osc which is used on the development board:
http://www.microchip.com/_ImagedCopy/microchiptechnologyinc_30262490421.jpg
http://www.digikey.com/product-detail/en/microchip-technology/DSC1001BC1-024.0000/DSC1001BC1-024.0000-ND/6192838
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: PIC32 external osc not working
« Reply #4 on: March 23, 2017, 10:50:15 am »
the silicon revision is the one listed when the programmer / debugger is connected to the pic
 

Offline Abstr7ct

  • Regular Contributor
  • *
  • Posts: 88
  • Country: 00
  • Learner
Re: PIC32 external osc not working
« Reply #5 on: March 23, 2017, 10:54:24 am »
You should load the resonator by 10pF capacitance. Typical circuit connection is shown below for your part.

« Last Edit: March 23, 2017, 10:59:12 am by Abstr7ct »
 

Offline mapexmbirchTopic starter

  • Contributor
  • Posts: 20
Re: PIC32 external osc not working
« Reply #6 on: March 23, 2017, 10:59:36 am »
Ah it's A1.

It says on the errata, the work around is to use an external clock.  Which pin do I apply this to?  Is it OSCI/CLKI?
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: PIC32 external osc not working
« Reply #7 on: March 23, 2017, 12:09:05 pm »
yes

question: what could one use ad an on board external clock source?
« Last Edit: March 23, 2017, 12:59:39 pm by JPortici »
 


Offline Niklas

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: se
Re: PIC32 external osc not working
« Reply #9 on: March 24, 2017, 06:40:50 am »
This issue is fixed on the A2 and A3 silicon revisions. One interesting feature with this bug is that it will brick the JTAG interface halfway through a firmware download. If that happens, then ICSP can be used to erase the device and bring it back to life.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf