Menu

Great Cow BASIC - ChipFiles

Anobium
2018-03-05
2024-10-19
  • Anobium

    Anobium - 2018-03-05

    This thread details the process for the production of MicroChip PIC chipfiles for Great Cow BASIC.

    The outcome of the process is a microcontroller specific DAT file. These files are located in the chipfiles folder of the Great Cow BASIC installation.

    A microcontroller specific DAT file is required for every microcontroller that Great Cow BASIC supports. The microcontroller specific DAT file contains information with respect registers, register bits, configuration options, memory, interrupts and microcontroller specific constraints (if any). This microcontroller specific DAT file is for Great Cow BASIC only - this is a good resource but the microcontroller specific DAT file should not be manually edited.

    All issues with respect to the microcontroller specific DAT file should be report via the forum.

    This post will explain how we produce these microcontroller specific DAT file.

    Tools

    1. MPLAB-X IDE - we will be using component of the MPASMX sub-directory. Great Cow BASIC uses filename.INC files as the primary data source for microcontroller configuration.
    2. PreProcess.BAT- the first part of the Great Cow BASIC conversion process. This uses GAWK.EXE - an Open Source application. PreProcessIncFile.bat is used for the first step of the conversion . The associated source script file is PreProcessIncFile.awk. PreProcessIncFile.awk is the script that is completes the conversion.
    3. GETCHIPDATA.EXE - a Great Cow BASIC specific application for conversion.
    4. Chipdata.cvs - a Great Cow BASIC specific data source. This file contains critical data with respect to microcontroller specific data.
    5. CriticalChanges.txt - a Great Cow BASIC specific data source. This file contains critical date with respect to microcontroller specific data. This file contains corrections to known bugs in the INC source files and how to correct them.

    Process to create and manage

    1. Update the source INC file from the latest MPLAB-X installation by copying the file from the source folder to the Incfiles\original folder . Download and install the latest MPLAB-X installation from the Microchip website, then,
      copy C:\Program Files (x86)\Microchip\MPLABX\v4\mpasmx\p1*.inc [target]DAT\incfiles\OrgFiles
    2. Execute PreProcess.bat. This will update or create the inc files in the [target]DAT\incfiles folder.
    3. Update CriticalChanges.txt for any known corrections.
    4. Update the Chipdata.cvs file with the correct chip data, see below.
    5. Execute getchipdata.exe > chipfiles/outputlog.txt. outputlog.txt will contain all the process messages.
    6. Copy to chipfiles to Gold distribution of Great Cow BASIC
    7. Update SourceForge: SVN:DAT

    Details of Chipdata.cvs

    There are a number of parameters. The majority are obvious, Those shown below are not that easy.

    PWMTimerVariant can be set to 0 or 1.

    Values will be set in the .dat using the following rule.

    Search for CCPTMRS in the specific datasheet and examine.

    PWMTimerVariant = 1.  When CCPTMRS or CCPTMRSX has PTxSEL  a value of 0x00 =Timer 2 and where PTxSEL=0x11 is reserved.
    
    The Default (no value present).  When PTxSEL as value=0x01 = Timer2 and PTxSEL=0xoo to be reserved, OR,  this register /bit combination is not present.  Which is the general case.
    

    SMTClockSourceVariant can be set to 1, 2 or 3.

    Values will be set in the .dat the following rule applies for SMTxCLK

    Search the specific datasheet for SMTxCLK

    SMTClockSourceVariant  = 0.  
            No SMT Clock source.
    
    SMTClockSourceVariant  = 1.
    
            Microcontroller does not support MFINTOSC (500KHz)
            SMT_MFINTOSC_16 = 4
            SMT_LFINTOSC = 3
            SMT_HFINTOSC = 2  '16MHz regardless of FOSC
            SMT_FOSC4 = 1
            SMT_FOSC = 0
    
    SMTClockSourceVariant  = 2.
    
            SMT_AT1_perclk = 6
            SMT_MFINTOSC = 5
            SMT_MFINTOSC_16 = 4
            SMT_LFINTOSC = 3
            SMT_HFINTOSC = 2 '16MHz regardless of FOSC
            SMT_FOSC4 = 1
            SMT_FOSC = 0
    
    SMTClockSourceVariant  = 3.
    
            SMT_REF_CLK = 7
            SMT_SOSC = 6
            SMT_MFINTOSC_16 = 5
            SMT_MFINTOSC = 4
            SMT_LFINTOSC = 3
            SMT_HFINTOSC = 2 '16MHz regardless of FOSC
            SMT_FOSC =  1
            SMT_FOSC4 = 0
    

    ConfigBaseLoc to be set in the .dat the following rule applies:

    Value are specific to the microcontroller and may need to be calculated.

    Search the specific datasheet for 'memory map' and examine if the CONFIG words are at 300000h

    Applies to 18f only and it is calculated at the  last location for the config memory address  minus 15
    
    An example,  18F67J50 the last location is 0x1FFFF, so the ConfigBaseLoc is 0x1FFFF - 15 = 0x1FFF0
    
    Default location for an 18F is from 0x300000.
    

    IntOSCCONFormat to be set in the .dat the following rule applies:
    Values are 1. The default is empty.

    Search the specific datasheet for HFIOFS bit

    Applies to PIC only examples are PIC10F322 and PIC18F13K22.  This is  required to ensure the clock oscillator is set correctly.  This chip will have HFIOFS bit.  The OSSCON bits for IRCFx are different for specific  chips.  The IntOSCCONFormat  enables  system.h to set the correct frequency bits.
    
    IntOSCCONFormat  = 1
    
        111 = 111 16 Mhz
        110 = 110   8 Mhz
        . . .
        000 = 0 31 kHz
    

    Attached is a PDF version of this post with further reference material in terms of example datasheet entries for the varaints.

    Anobium March 2018

     

    Last edit: Anobium 2018-12-16
  • Anobium

    Anobium - 2018-03-05

    The post details the chipfile data format.

    'Config options
    'Ram size, other specs
    'Chip family
    'Registers and locations
    'Bits and locations
    
    'example using 16F819
    
    [ChipData]
    Prog=2048
    EEPROM=256
    RAM=256
    I/O=16
    ADC=5
    MaxMHz=20
    IntOsc=8
    Pins=18
    Family=14
    ConfigWords=1
    PSP=0
    
    [Registers]
    INDF,0
    TMR0,1
    PCL,2
    etc ...
    
    [Bits]
    IRP,STATUS,7
    RP1,STATUS,6
    etc ...
    
    [FreeRAM]
    'start:end (inclusive)
    32:127
    96:255
    etc
    
    [Pins]
    Type:DIP
    1:RA2(IO),AN2(I),Vref-(I)
    2:RA3(IO),AN3(I),Vref+(I)
    3:RA4(IO),AN4(I),T0CKI(I)
    4:RA5(I),MCLR,Vpp
    5:Vss
    6:RB0(IO),INT(I)
    etc
    
    [Interrupts]
    'On PIC
    Name:Enable,Flag
    'On AVR
    Name:Vector,VectorLoc,Enable,Flag
    
    '18F only:
    'Assembler default config
    [ASMConfig]
    MCLRE=ON
    etc
    
    [DisplayConfig]
    CP=ALL,OFF
    OSC=HS,XT,EC,INT
    etc
    
    [Config]
    CP_ALL,1,value
    CP_OFF,1,value
    etc
    
     
  • Anobium

    Anobium - 2018-03-05

    Do not post to this thread - this is a reference/master thread.

    Please create a new thread to discuss any aspect.

    Thank you.

     

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.