Trouble setting 16F1939 to 32mhz with intosc. (PLL X4 not working)


+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2013
    Posts
    1,122

    Default Trouble setting 16F1939 to 32mhz with intosc. (PLL X4 not working)

    Hello.
    This is my config:

    Code:
    '****************************************************************
    ;----[16F1937 Hardware Configuration]-------------------------------------------
    #IF __PROCESSOR__ = "16F1939"
      #DEFINE MCU_FOUND 1
    #CONFIG
    cfg1 = _FOSC_INTOSC           ; INTOSC oscillator: I/O function on CLKIN pin
    cfg1&= _WDTE_OFF              ; WDT disabled
    cfg1&= _PWRTE_OFF             ; PWRT disabled
    cfg1&= _MCLRE_OFF             ; MCLR/VPP pin function is digital input
    cfg1&= _CP_ON                 ; Program memory code protection is enabled
    cfg1&= _CPD_OFF               ; Data memory code protection is disabled
    cfg1&= _BOREN_OFF             ; Brown-out Reset disabled
    cfg1&= _CLKOUTEN_OFF          ; CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin
    cfg1&= _IESO_ON               ; Internal/External Switchover mode is enabled
    cfg1&= _FCMEN_ON              ; Fail-Safe Clock Monitor is enabled
      __CONFIG _CONFIG1, cfg1
    
    
    cfg2 = _WRT_OFF               ; Write protection off
    cfg2&= _VCAPEN_OFF            ; All VCAP pin functionality is disabled
    cfg2&= _PLLEN_ON             ; 4x PLL enabled
    cfg2&= _STVREN_ON             ; Stack Overflow or Underflow will cause a Reset
    cfg2&= _BORV_19               ; Brown-out Reset Voltage (Vbor), low trip point selected.
    cfg2&= _LVP_OFF               ; High-voltage on MCLR/VPP must be used for programming
      __CONFIG _CONFIG2, cfg2
    
    
    #ENDCONFIG
    
    
    #ENDIF
    
    
    ;----[Verify Configs have been specified for Selected Processor]----------------
    ;       Note: Only include this routine once, after all #CONFIG blocks
    #IFNDEF MCU_FOUND
      #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
    #ENDIF
    
    
    'nixie led clock electronics direct drive
    
    
    DEFINE ADC_BITS 10       ' Set number of bits in result
    DEFINE ADC_CLOCK 3     ' Set clock source (rc = 3)
    DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds 
    
    
     
    ADCON1=%11110011 'enable adc internal reference and justify
    FVRCON=%11001111   'set internal reference to 4.096V
    OSCCON=%11110001  'SET INTOSC TO 8MHZ and enable 4X PLL
    ANSELE=%00000001 'enable adc input porte.0
    ANSELA=%00000000 'disable ADC on A
    ANSELB=%00000000 'disable ADC on B
    ANSELD=%00000000 'disable ADC on D
    TRISC=%00000000 'set PORTC as output all
    TRISD=%00000000 'set PORTD as output all
    TRISB=%00000000 'set PORTB as output all
    TRISA=%00000000 'set PORTA 2 as input, others as output
    TRISE=%00000001  'set PORTE as output all except 0
    WPUB=%00000000 'DISABLE B PULL UPS
    OPTION_REG=%100000000  'disable other pull ups
    LCDCON=%00000000  'disable LCD controller pins
    LCDSE0=%00000000
    LCDSE1=%00000000
    LCDSE2=%00000000
    
    
    DEFINE OSC 32 'set oscillator speed
    It should run on 32mhz (8mhz clock * 4x PLL). However, it runs on 8mhz. If I set it to 16mhz, it works fine on 16mhz. So I guess, somehow, PLL setting is ignored. What I'm doing wrong?

    I tried to play with PLL registers, but no luck...

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: Trouble setting 16F1939 to 32mhz with intosc. (PLL X4 not working)

    If PLLEN in Configuration Words = 1, SPLLEN bit is ignored. 4x PLL is always enabled (subject to oscillator requirements)

    why are selecting Timer1 oscillator for fosc ? its incapable of 32mhz operation or pll
    Warning I'm not a teacher

  3. #3
    Join Date
    Feb 2013
    Posts
    1,122


    Did you find this post helpful? Yes | No

    Default Re: Trouble setting 16F1939 to 32mhz with intosc. (PLL X4 not working)

    Thanks!
    Yes it was my error - set OSCCON=%11110000 and now it seems to be working correctly.

Similar Threads

  1. 18F2620 32mhz pll and Timer1 250ms ticks
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th February 2017, 17:15
  2. Bootloader pic16f1825 @32mhz pll
    By richard in forum General
    Replies: 10
    Last Post: - 13th July 2016, 12:42
  3. Replies: 2
    Last Post: - 3rd January 2014, 01:53
  4. Using INTOSC 32Mhz as RF Radio Control and Data Communication
    By rayzrocket in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 13th January 2011, 12:10
  5. Can't get 18F2221 PLL to run with INTOSC
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 5th February 2008, 21:26

Members who have read this thread : 11

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts