Menu

Oscillator cannot be configured with INTRC_OSC_CLKOUT for the PIC12F683

2022-05-11
2022-05-12
  • Dave Schindel

    Dave Schindel - 2022-05-11

    I was using Great Cow Graphical Basic to make a simple timer program for a project. Everything was going well and the complied code worked.

    I then I wanted to change the clock speed from 4 MHz to 125KHz to reduce power so I made the configuration setting change in the PROGRAM>HARDWARE SETTINGS menu of great cow graphical basic.

    I then decided it would be nice to make sure the oscillator was really running at 125KHz so I also changed from INTRC_OSC_NOCLKOUT to INTRC_OSC_CLKOUT. After compiling and burning the hex into the 12F683, I then checked the frequency output on the CLK OUT pin of the 12F683 and found it was around 1 MHz. This should be 125KHz/4 or 31.25Khz so I looked at the assembly file generated by great cow and noticed that it did not generate the oscillator configuration part of the code that it did when I selected INTRC_OSC_NOCLKOUT.

    The assembly code for the OSCCON register was completely missing. I was able to get things working by adding the OSCCON code in and using MPLAB to create the working HEX file but that is extra work that is a hassle to do so wanted to point out this bug. Attached are some screen shots to help clarify my settings. I highlighted the code that is missing when I tried to configure the clock as INTRC_OSC_CLKOUT.

     

    Last edit: Anobium 2022-05-11
  • Anobium

    Anobium - 2022-05-11

    Opps. Can you post the errant program?. So, we can reproduce and fix.

    Post the GCB and the ASM GCGB created to the post, as attachments.


    However, I have resolved in build 1120

    As a user of GCGB I have no idea how you installed but you need to update to the latest build regardless to get build 1120.

     

    Last edit: Anobium 2022-05-11
  • Dave Schindel

    Dave Schindel - 2022-05-11

    How can I check which build I have?
    The Great Cow Basic code I used was very short just to test this. It is:

    ;Chip Settings
    #chip 12F683,0.125
    #config OSC=INTRC_OSC_CLKOUT
    

    The assembly generated by Great Cow Basic was:

    ;Program compiled by Great Cow BASIC (0.99.01 2022-01-27 (Windows 64 bit) : Build 1073) for Microchip MPASM
    ;Need help? See the GCBASIC forums at http://sourceforge.net/projects/gcbasic/forums,
    ;check the documentation or email w_cholmondeley at users dot sourceforge dot net.
    
    ;********************************************************************************
    
    ;Set up the assembler options (Chip type, clock source, other bits and pieces)
     LIST p=12F683, r=DEC
    #include <P12F683.inc>
     __CONFIG _FCMEN_ON & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _WDTE_OFF & _INTRC_OSC_CLKOUT
    
    ;********************************************************************************
    
    ;Vectors
        ORG 0
        pagesel BASPROGRAMSTART
        goto    BASPROGRAMSTART
        ORG 4
        retfie
    
    ;********************************************************************************
    
    ;Start of program memory page 0
        ORG 5
    BASPROGRAMSTART
    ;Call initialisation routines
        call    INITSYS
    
    ;Start of the main program
    ;Chip Settings
    BASPROGRAMEND
        sleep
        goto    BASPROGRAMEND
    
    ;********************************************************************************
    
    ;Source: system.h (156)
    INITSYS
    ;asm showdebug _For_selected_frequency_-_the_external_oscillator_has_been_selected_by_compiler ChipMHz
    ;asm showdebug _Complete_the_chip_setup_of_BSR,ADCs,ANSEL_and_other_key_setup_registers_or_register_bits
    ;Ensure all ports are set for digital I/O and, turn off A/D
    ;SET ADFM OFF
        bcf ADCON0,ADFM
    ;Switch off A/D Var(ADCON0)
    ;SET ADCON0.ADON OFF
        bcf ADCON0,ADON
    ;ANSEL = 0
        banksel ANSEL
        clrf    ANSEL
    ;CMCON0 = 7
        movlw   7
        banksel CMCON0
        movwf   CMCON0
    ;
    ;'Turn off all ports
    ;GPIO = 0
        clrf    GPIO
        return
    
    ;********************************************************************************
    
    
     END
    
     
  • Anobium

    Anobium - 2022-05-12

    Thank you. You have (0.99.01 2022-01-27 (Windows 64 bit) : Build 1073) build 1073.

    You need build 1121.


    Goto https://sourceforge.net/projects/gcbasic/files/Release%20Candidates/Patches/

    • Download the zip
    • unzip all files to a temp folder
    • apply all files to your installation replacing all the existing files
    • then, rename the compiler EXE for your operating system - you need to ensure either GCBASIC64.exe or GCBASIC32.exe is renamed as GCBASIC.exe for your operating system
    • Enjoy

    Using single files may make your installation unstable. Use all the patch files.

    See https://1drv.ms/x/s!Ase-PX_n_4cvhJAysbPF3VJAnYaj3A for changelog.


    There was an issue in build 1120... it always set the CLOCKOUT.. you need 1121. I will post when I have uploaded.

     

    Last edit: Anobium 2022-05-12
  • Anobium

    Anobium - 2022-05-12

    Uploaded build 1121

    Goto https://sourceforge.net/projects/gcbasic/files/Release%20Candidates/Patches/

    1. Download the zip
    2. unzip all files to a temp folder
    3. apply all files to your installation replacing all the existing files
    4. then, rename the compiler EXE for your operating system - you need to ensure either GCBASIC64.exe or GCBASIC32.exe is renamed as GCBASIC.exe for your operating system
    5. Enjoy

    Do not use single files from the zip - this may make your installation unstable. Use all the patch files.

    See https://1drv.ms/x/s!Ase-PX_n_4cvhJAysbPF3VJAnYaj3A for changelog.

     
  • Dave Schindel

    Dave Schindel - 2022-05-12

    Everything worked smoothly with the new 1121 build. Thanks for the fast update!

     
  • Anobium

    Anobium - 2022-05-12

    Pleasure, a worthwhile change. I will expand this change over the next few weeks.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.