Announcement

Collapse
No announcement yet.

Help with 18F2680 for Internal 32 MHz configuration

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with 18F2680 for Internal 32 MHz configuration

    Hi All,
    I am using 18F2680 (PBP V3.0.6.4 with MicroCode V5.0.0.3).
    I am trying to config it for 32 MHz internal Osc but having problems, missing something?

    The 18F2680 is working on my test program but the pulses should be 30ms and the logic analyzer is showing the pulses as 119ms apart and of course the HSEROUT2 doesn't work due to the timing.

    Here is my test program. Note: I have a large program which was working on an external 20MHz and I've copied and past it into the new test program except for the Osc.

    18F2680 Chip

    #CONFIG
    CONFIG OSC = HSPLL
    CONFIG FCMEN = ON
    CONFIG IESO = ON
    CONFIG PWRT = ON
    CONFIG BOREN = SBORENCTRL
    CONFIG BORV = 3
    CONFIG WDT = ON
    CONFIG WDTPS = 1
    CONFIG MCLRE = ON
    CONFIG LPT1OSC = OFF
    CONFIG PBADEN = OFF
    CONFIG STVREN = OFF
    CONFIG LVP = OFF
    CONFIG XINST = OFF
    CONFIG DEBUG = OFF
    CONFIG CP0 = OFF
    CONFIG CP1 = OFF
    CONFIG CP2 = OFF
    CONFIG CP3 = OFF
    CONFIG CPB = OFF
    CONFIG CPD = OFF
    CONFIG WRT0 = OFF
    CONFIG WRT1 = OFF
    CONFIG WRT2 = OFF
    CONFIG WRT3 = OFF
    CONFIG WRTC = OFF
    CONFIG WRTB = OFF
    CONFIG WRTD = OFF
    CONFIG EBTR0 = OFF
    CONFIG EBTR1 = OFF
    CONFIG EBTR2 = OFF
    CONFIG EBTR3 = OFF
    CONFIG EBTRB = OFF
    CONFIG BBSIZ = 2048
    #ENDCONFIG

    OSCCON = %01110000 ' Internal Oscillation at 32 MHz
    OSCTUNE = %01000000

    DEFINE OSC 32 ' Defining chip as 32 MHz

    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 64 ' 9600 Baud @ 32MHz, 0.04%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically

    TRISA = %00000010 ' Make PortA in's and out's
    TRISB = %00110000 ' Make PortB in's and out's
    TRISC = %10010000 ' Make PortC in's and out's

    ADCON1 = %00001111 ' Configuring the analog/digital I/O Pins
    ADCON0 = %00000000 ' Configuring the analog/digital I/O Pins

    Sincerely would appreciate any help.
    Lyle

  • #2
    In order for the PLL to work with the Internal Oscillator, the internal must be set as the "Primary Oscillator".

    Change your CONFIG OSC = HSPLL to ...

    CONFIG OSC = IRCIO67
    PBP3 Manual : Microchip Datasheets - 10F, 12F, 16F, 18F
    Never download a PIC datasheet from anywhere but microchip.com

    Comment


    • #3
      Thanks for the reply,
      Yes, I tried the IRCIO67 instead of HSPLL and still get the same results.
      I've turned the FCMEN = OFF & IESO = OFF.

      I also changed;
      OSCCON = %011111110
      OSCTUNE = %100011111

      Still getting the same results? Am I missing a command or am I just blowing the registers config?
      Thanks for any help,
      Lyle

      Comment


      • #4
        Maybe when you tried it, something else in your program was different.

        I've run your program from post #1 and changed it to CONFIG OSC = IRCIO67.
        Added this Main loop, and it blinks at 1Hz (a.k.a. running at 32Mhz).

        Code:
        Main:
            TOGGLE PORTB.0
            PAUSE 500
        GOTO Main
        The 18F2680 is working on my test program but the pulses should be 30ms and the logic analyzer is showing the pulses as 119ms apart and of course the HSEROUT2 doesn't work due to the timing.
        How are you generating the pulses?

        And I'm still confused.
        In your other thread, we determined you are using SERIN2. But here you're talking about HSEROUT2 again, with defines for HSEROUT (the first port).

        Might help if you posted the whole program.
        PBP3 Manual : Microchip Datasheets - 10F, 12F, 16F, 18F
        Never download a PIC datasheet from anywhere but microchip.com

        Comment


        • #5
          Hi, I wanted to thank you for your help...

          Yes I am using SERIN2 - PORTC.4, SEROUT2 - PORTC.5 AND HSERIN - PORTC.7, HSEROUT - PORTC.6 in my main 18F2680 program.
          The program is about 48,000 bytes, so I don't think you want to deal with the whole program. Every thing is working properly using an external 20MHz crystal. What I am trying to do is to change the config's to an internal 32MHz.

          With what I have in the configuration (test program) using the internal osc at 32MHz, the LED's are flashing, but using 'pause 30' between the led, show up on my analyzer as a 106.9ms flash.
          So, I know the Osc config can't be correct.

          This is my 32MHz test program that I am trying to work.


          #CONFIG
          CONFIG OSC = IRCIO67
          CONFIG FCMEN = OFF
          CONFIG IESO = OFF
          CONFIG PWRT = ON
          CONFIG BOREN = SBORENCTRL
          CONFIG BORV = 3
          CONFIG WDT = ON
          CONFIG WDTPS = 1
          CONFIG MCLRE = ON
          CONFIG LPT1OSC = OFF
          CONFIG PBADEN = OFF
          CONFIG STVREN = OFF
          CONFIG LVP = OFF
          CONFIG XINST = OFF
          CONFIG DEBUG = OFF
          CONFIG CP0 = OFF
          CONFIG CP1 = OFF
          CONFIG CP2 = OFF
          CONFIG CP3 = OFF
          CONFIG CPB = OFF
          CONFIG CPD = OFF
          CONFIG WRT0 = OFF
          CONFIG WRT1 = OFF
          CONFIG WRT2 = OFF
          CONFIG WRT3 = OFF
          CONFIG WRTC = OFF
          CONFIG WRTB = OFF
          CONFIG WRTD = OFF
          CONFIG EBTR0 = OFF
          CONFIG EBTR1 = OFF
          CONFIG EBTR2 = OFF
          CONFIG EBTR3 = OFF
          CONFIG EBTRB = OFF
          CONFIG BBSIZ = 2048
          #ENDCONFIG

          OSCCON = %01111110 ' Internal Oscillation at 32 MHz
          OSCTUNE = %10001111

          DEFINE OSC 32 ' Defining chip as 32 MHz

          DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
          DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
          DEFINE HSER_SPBRG 64 ' 9600 Baud @ 32MHz, 0.04%
          DEFINE HSER_CLROERR 1 ' Clear overflow automatically

          TRISA = %00000010 ' Make PortA in's and out's
          TRISB = %00110000 ' Make PortB in's and out's
          TRISC = %10010000 ' Make PortC in's and out's

          ADCON1 = %00001111 ' Configuring the analog/digital I/O Pins
          ADCON0 = %00000000 ' Configuring the analog/digital I/O Pins

          I VAR WORD ' I for loops

          '********************************************************
          MAIN:
          PAUSE 500 ' Pause for chip to set up osc
          HSEROUT [$55] ' Send U to uLCD-32PT LCD to cancel default screen
          GOSUB ACKN ' Wait for acknowledge from uLCD
          PAUSE 100 ' Pause - not really needed
          MAIN2:
          TOGGLE LATC.1
          PAUSE 30
          GOTO MAIN2

          '******************************************************
          ACKN:
          WHILE PORTC.7 = 1 ' While receiving command wait
          WEND ' After command end While
          RETURN ' Return from GOSUB requested

          '******************************************************
          END

          Comment


          • #6
            You've changed the OSCCON and OSCTUNE from what it was in post#1, and it's no longer set for the Primary oscillator (OSCCON<1:0>) with PLL (OSCTUNE.6). Change them back to ...

            OSCCON = %01110000 ' Internal Oscillation at 32 MHz
            OSCTUNE = %01000000


            Also, you can't use TOGGLE on any LATx registers.
            You can only use it on PORTx.x.

            If you have TOGGLE on LATA.x in your real program, it can overwrite the OSCTUNE register. TOGGLE LATC.x will overwrite the PIE1 register.

            This applies to most of the other PBP commands as well. Don't use LATx.x unless it is a direct assignment, ie....

            LATC.1 = 1

            -or-

            LATC.1 = !LATC.1 ; toggle using LAT
            PBP3 Manual : Microchip Datasheets - 10F, 12F, 16F, 18F
            Never download a PIC datasheet from anywhere but microchip.com

            Comment


            • #7
              Hi Darrel,
              I didn't realize that the TOGGLE would still work but change the osc, thank you for bringing that up to me.

              I changed the OSCCON & OSCTUNE back to what I had, took out the Latch for the Toggle and... yes, it worked. I think I was just trying to keep changing things till it worked! I new I was close but the Toggle Latch kept it from working and I didn't know it.
              Originally I did have the OSC = IRCIO67 but it never worked and change it before sending it off for help.

              It's always the little things that you don't catch that gets you in the end...

              Thanks for your help and patience.
              Lyle

              Comment

              Working...
              X