CONFIGS? setting PIC fuses? Configurations of Hardware settings of a PIC.


Results 1 to 18 of 18

Threaded View

  1. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: CONFIGS? setting PIC fuses? Configurations of Hardware settings of a PIC.

    Hi,
    PBP has a default CONFIG for each chip which is located in the .inc file (in the PBP folder) for the specific chip. If you want to set the CONFIG from within your program you must comment out the default CONFIG in the .inc file. If you leave the default in the .inc file AND put your own in the program you'll get an error because they are then conflicting with each other.

    Note that setting the CONFIG bits is not actually part of the PBP program, it's nothing that gets done when the program runs. It's just a way to embedd them into the .hex file so that you don't have to manually change them in the device programmer software.

    If you look section 25.1 in the datasheet for the 18F4550 you'll see the various CONFIG registers for the device. If you continue to read there's an explenation for each and every bit in each of these registers in the following pages.

    Now, let's take a look at the following line, what does it actually do:
    __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L

    Well, __CONFIG is the assembler directive to tell the assembler that we are setting CONFIG bits. _CONFIG1L is the name of register we are setting and the rest are the actual settings. If you open up the MPASM Suite folder of your MPLAB installation you'll find a bunch of .INC files (note that these are not equivalent to the .inc files in the PBP folder). If you open up the one for the 18F4550 (P18F4550.INC) and scroll down towards the bottom you'll find the definitions for the constants in the above statement:
    Code:
    ;----- CONFIG1L Options --------------------------------------------------
    _PLLDIV_1_1L         EQU  H'F8'    ; No prescale (4 MHz oscillator input drives PLL directly)
    _PLLDIV_2_1L         EQU  H'F9'    ; Divide by 2 (8 MHz oscillator input)
    _PLLDIV_3_1L         EQU  H'FA'    ; Divide by 3 (12 MHz oscillator input)
    _PLLDIV_4_1L         EQU  H'FB'    ; Divide by 4 (16 MHz oscillator input)
    _PLLDIV_5_1L         EQU  H'FC'    ; Divide by 5 (20 MHz oscillator input)
    _PLLDIV_6_1L         EQU  H'FD'    ; Divide by 6 (24 MHz oscillator input)
    _PLLDIV_10_1L        EQU  H'FE'    ; Divide by 10 (40 MHz oscillator input)
    _PLLDIV_12_1L        EQU  H'FF'    ; Divide by 12 (48 MHz oscillator input)
    
    _CPUDIV_OSC1_PLL2_1L EQU  H'E7'    ; [Primary Oscillator Src: /1][96 MHz PLL Src: /2]
    _CPUDIV_OSC2_PLL3_1L EQU  H'EF'    ; [Primary Oscillator Src: /2][96 MHz PLL Src: /3]
    _CPUDIV_OSC3_PLL4_1L EQU  H'F7'    ; [Primary Oscillator Src: /3][96 MHz PLL Src: /4]
    _CPUDIV_OSC4_PLL6_1L EQU  H'FF'    ; [Primary Oscillator Src: /4][96 MHz PLL Src: /6]
    
    _USBDIV_1_1L         EQU  H'DF'    ; USB clock source comes directly from the primary oscillator block with no postscale
    _USBDIV_2_1L         EQU  H'FF'    ; USB clock source comes from the 96 MHz PLL divided by 2
    So, _PLLDIV_5_1L equals FC, _CPUDIV_OSC1_PLL2_1L equals E7 and _USBDIV_2_1L equals FF. If we AND those together, which is what the statement does, we get E4 or 11100100 in binary. Now go back to the datasheet and put those ones and zeros into the CONFIG1L register.

    Bits 2-0 are the PLL prescaler bits, they are being set to 100 which means divide by 5 (20MHz oscillator input). This matches nicely with the named constant _PLLDIV_5_1L
    Bits 4-3 are the System Clock Postscaler selection bits. These means different things depending on another setting but when used with the PLL and set to 00 the divider is set to 2 for a system clock of 96MHz/2=48Mhz. Again the named constant _CPUDIV_OSC1_PLL2_1L matches the what's actually happening.
    Bit 5 is the USB Clock Selection bit, we're setting it to 1 which means USB clock source comes from the 96 MHz PLL divided by 2 which again matches the named constant _USBDIV_2_1L

    And it's the same for all the other CONFIG registers. Just remember that this is just a way to tell the assembler what to embedd in the .hex file so that the device programmer can program the correct the CONFIG bits into the device without having the user set them in the software for the device programmer. It's not the same as doing something like T1CON = %00010010 which actually executes at runtime.

    I hope this sheds some more light on the subject and that I'm not too far from the truth, in which case I'm sure someone will jump in and correct me.

    /Henrik.
    Last edited by HenrikOlsson; - 4th January 2013 at 10:15.

Similar Threads

  1. IR trasmitter using PIC 16F84 and NE555
    By tonixxx in forum mel PIC BASIC
    Replies: 1
    Last Post: - 27th December 2012, 00:55
  2. How do I program a pic to accept inputs?
    By timbear3 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 2nd December 2012, 00:35
  3. Replies: 7
    Last Post: - 20th November 2012, 19:41
  4. Which pic? up to date basic chip for 16f877
    By tasmod in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 19th November 2012, 11:26
  5. How not to prototype your next PIC project
    By SteveB in forum General
    Replies: 3
    Last Post: - 12th November 2012, 09:35

Members who have read this thread : 1

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