Looking for Enhanced Mid-range PIC ref manual

Status
Not open for further replies.
Yes, it's quite tricky to get the oscillator speeds set correctly - particularly for 32MHz, as it's not just a matter of the config fuses, you have to set registers as well. Here's the C routine for setting mine to 32MHz, generated by MCC.

C:
void OSCILLATOR_Initialize(void)
{
    // NOSC HFINTOSC with 2x PLL; NDIV 1;
    OSCCON1 = 0x10;
    // CSWHOLD may proceed; SOSCPWR Low power;
    OSCCON3 = 0x00;
    // MFOEN disabled; LFOEN disabled; ADOEN disabled; SOSCEN enabled; EXTOEN disabled; HFOEN disabled;
    OSCEN = 0x08;
    // HFFRQ 16_MHz;
    OSCFRQ = 0x05;
    // HFTUN 0;
    OSCTUNE = 0x00;
    // Wait for PLL to stabilise
    while(PLLR == 0)
    {
    }
}
 
Thanks, Bob. The '1703 clock setup is rather tame compared to the 15000 and 18000 series. Like Nigel's example, I let MCC setup the clock for me on a 16F15325 project and copied and pasted the settings into my source file.
Code:
/*                                                                      *
 *   configure INTOSC for 16-MHz (no PLL)                               *
 *                                                                      */
     OSCCON1 = 0x60;        // hfintosc, ndiv 1
     OSCCON3 = 0x00;        // cswhold may proceed; soscpwr Low power
     OSCEN = 0x00;          // MFOEN,LFOEN,ADOEN,EXTOEN,HFOEN disabled
                            // SOSCEN enabled
     OSCFRQ = 0x05;         // HFFRQ 16-MHz
     OSCSTAT = 0x00;        // MFOR not ready;
     OSCTUNE = 0x00;        // HFTUN 0;
I also wanted bit-level control of the Power Management module control registers which involved a little bit of research. However, now it's easier (for me) to identify and turn individual peripherals on or off.
Code:
   void main()
   { PMD0 = 0<<_PMD0_SYSCMD_POSN |  // Clock network 'on'
            1<<_PMD0_FVRMD_POSN  |  // FVR module off
            0<<_PMD0_NVMMD_POSN  |  // NVM module 'on'
            1<<_PMD0_CLKRMD_POSN |  // CLKR module off
            1<<_PMD0_IOCMD_POSN;    // IOC module off

     PMD1 = 1<<_PMD1_NCOMD_POSN  |  // NCO module off
            1<<_PMD1_TMR2MD_POSN |  // TMR2 module off
            1<<_PMD1_TMR1MD_POSN |  // TMR1 module off
            1<<_PMD1_TMR0MD_POSN;   // TMR0 module off
     
     PMD2 = 1<<_PMD2_DAC1MD_POSN |  // DAC1 module off
            1<<_PMD2_ADCMD_POSN  |  // ADC module off
            1<<_PMD2_CMP2MD_POSN |  // C2 module off
            1<<_PMD2_CMP1MD_POSN |  // C1 module off
            1<<_PMD2_ZCDMD_POSN;    // ZCD module off

     PMD3 = 1<<_PMD3_PWM6MD_POSN |  // PWM6 module off
            1<<_PMD3_PWM5MD_POSN |  // PWM5 module off
            1<<_PMD3_PWM4MD_POSN |  // PWM4 module off
            1<<_PMD3_PWM3MD_POSN |  // PWM3 module off
            1<<_PMD3_CCP2MD_POSN |  // CCP2 module off
            1<<_PMD3_CCP1MD_POSN;   // CCP1 module off

     PMD4 = 1<<_PMD4_UART2MD_POSN | // UART2 module off
            1<<_PMD4_UART1MD_POSN | // UART1 module off
            1<<_PMD4_MSSP1MD_POSN | // MSSP1 module off
            1<<_PMD4_CWG1MD_POSN;   // CWG1 module off

     PMD5 = 1<<_PMD5_CLC4MD_POSN |  // CLC4 module off
            1<<_PMD5_CLC3MD_POSN |  // CLC3 module off
            1<<_PMD5_CLC2MD_POSN |  // CLC2 module off
            1<<_PMD5_CLC1MD_POSN;   // CLC1 module off
Gosh, these chips are getting quite sophisticated and it's taking me a lot longer to setup my projects.

Good luck. Have fun.

Cheerful regards, Mike
 
The '1703 clock setup is rather tame compared to the 15000 and 18000 series.
Yes. In the end, there wasn't much to it. The 32 MHz setting was a bit puzzling though, because of 4xPLL setting requirements, that weren't completely obvious. Since this was my first experience with the enhanced midrange line, it was a bit daunting, seeing the large number of various configuration registers. In the end, most of them could be ignored.

I will mention one thing that may save people some problems: Disable the slew rate limiting on the output pins until you're sure that it won't cause any problems. I found that this slowed the rise time too much on some output lines that were used for clocking external devices.
 
One gotcha that I'm sure you are aware of, but in case someone else is not, is the speed the internal oscillator defaults to under a reset such as being programmed from an ICSP. In the case of the PIC16F1703 the default speed is 500kHz. I don't use this particular micro, but I have used plenty of others to be aware of this.

"Following any Reset, the IRCF<3:0> bitsof the OSCCON register are set to ‘0111’ and the frequency selection is set to 500 kHz. The user can modify the IRCF bits to select a different frequency."
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…