Menu

Various considerations

Gigi
2016-11-12
2016-11-16
  • Gigi

    Gigi - 2016-11-12

    I always used PicBasic, a few months I'm doing a lot of work with the GCB and I'm learning to use it, it generates a larger HEX code PBP but has the advantage of creating a readable ASM and there are many libraries.

    I have version 0.95.010 I did not understand whether charge automatically calibrating oscillator for PIC12F629, testing with the simulator seems not working, I was using this code:
    '- LOAD calibration 1K internal oscillator
    osccal = peek (0x3FF)

    I do not understand why you can not store bytes of EEPROM in the HEX file as do all compilers without having to create a table that uses Code:
    '- EEPROM PROGRAMMER
    'ORG 0x2100 + 0x7F
    'De 00
    it would be convenient to implement this possibility that you fail with the above code.
    you can use multi-line comments as in C.

    I thank you and I apologize if I made all these requests.
    Gigi

     
  • Anobium

    Anobium - 2016-11-13

    Welcome - thanks for the positive feedback. Let us look at the considerations. No issue to to ask - if, you do not ask... we cannot make better!

    1. Set OSCCAL. Thought we had fixed Great Cow BasIC to load the saved calibration data into OSCCAL register on Baseline PIC in fix [515]. Can you please post your explicit code example to help me understand?
    2. ASM DE. We have had a few discussions on this. I do not remember where we ended up after the discussion but... you could.... generate the ASM using Great Cow BASIC then generate HEX using MPASM.
    3. Multi-line comments as in C. I no not understand this one. Can you explain?

    Pleasure,

    Anobium

     
  • Gigi

    Gigi - 2016-11-13

    Thank you for your quick response
    1) I put at the end of test code, the product ASM oscillator is:

    INITSYS
    ; Movwf OSCCAL
        banksel OSCCAL
        movwf OSCCAL
    

    It does not seem to read the value to be loaded. I tried with RealSimulator and is not loaded properly.
    2) I read old posts but I feel very uncomfortable manually write the code in asm and pass it to MPLAB file.

    3) simply meant something like / * --------- * / very useful when I have to remove a lot of lines of code for testing.
    Gigi

    ' -- freq=4/4 1Mhz -- 1uS per istruzione
    #chip 12F629,4          'Velocità in Mhz oscillatore interno
    #config INTRC_OSC_NOCLKOUT, WDT_OFF, MCLR_Off, BOD_on, PWRT_on
    
    #option explicit    'dichiarazione variabile obbligatoria
    
    ' -- EEPROM PROGRAMMER
    '   ORG 0x2100 + 0x7F
    '   de 00
    
    
    ' - acquisisce il codice automaticamente (mettere Jmp poi accendere, dare TX
    ' - telecomando entro 5 secondi, togliere Jmp)
    '===========================================================================
    '*****  SETTAGGIO PORTE
    'Pin 1 - Vdd +5V
    #define IO     GPIO.0     'pin_7 / OUT decode  1=ON
    #define Txc    GPIO.1     'pin_6 / TX code
    #define P1     GPIO.2     'pin_5 / Pulsante TX  0=TX
    #define Jmp    GPIO.3     'pin_4 / (solo input) JUMP code 0=auto-apprendimento
    #define Inp    GPIO.4     'pin_3 / INP code rx433
    #define Led    GPIO.5     'pin_2 / OUT led segnalazione 1=ON
    'Pin 8 - Vss GND
    '============ VARIABILI ===========================================
    #define Code_b     0x20          ' N. time
    
    dim Code (15)   as byte         ' MAX byte disponibili X ARRAY
    dim Temp2       as byte
    dim Temp1       as byte
    dim Temp        as byte     at 50
    dim Temp3             as byte
    dim Wtemp               as word
    dim Stato       as byte        ' FLAG controllo errori ecc.
    
    
    '==== SETTAGGI DELLE PORTE DEL PIC I/O ======================
    reset:
    'CMCON  = 7                   ' disabilita Comparatori (impostato automaticamente)
    'ANSEL  = 0                   ' seleziona canali ADC or DIGITAL
    'ADCON0  = b'00000000'
    WPU     = b'00001100'         ' PIN Pull-up 1=ON  0=OFF (bit3 non settabile)
    
    
    ' -- CARICA calibrazione oscillatore interno 1K
    'osccal=peek(0x3FF)
    
    ' --------  bit a bit controllo 0=output  1=input  (bit3 non settabile)
    dir GPIO b'01011100'     ' bit a bit controllo 0=output  1=input
    
    
    ' -- TIMER0
    'psa =0 : t0cs = 0                  ' attiva timer0
    OPTION_REG=b'11010010'      ' prescaler 1/8  step 10uS circa
    
    ' -- TIMER1              ' Timer1 ON -- prescaler /8
    't1con = b'00100000'        '
    'TMR1GE = 1         ' attiva PIN T1Gate
    'SetTimer 1, ps1_8              '   prescaler
    
    wait 500 ms                   ' RITARDO impulsi spuri
    
    
    do
    '/*
    '       Multi-line comments as in C
    '       Multi-line comments as in C
    '       Multi-line comments as in C
    '*/
    
    loop
    
     

    Last edit: Anobium 2016-11-13
  • Anobium

    Anobium - 2016-11-13

    Ok. Here goes.

    1. Try on a real chip. I cannot see why this is not working. Here is the ASM for your chip, shown below from v.0.95.010. If this does not work on a real chip then do let us know.
    ;********************************************************************************
    
    INITSYS
    ;movwf OSCCAL
        banksel OSCCAL
        movwf   OSCCAL
    ;CMCON = 7
        movlw   7
        banksel CMCON
        movwf   CMCON
    ;GPIO = 0
        clrf    GPIO
        return
    
    ;********************************************************************************
    
    1. OK. We can think on this. Added to the list but no commitment on timing.
    2. You can do this today in the IDE. See Edit/Toggle Comments in the IDE. But, ok I get the ask. We can think on this but I do not see this as being a priority item. Sorry.
    3. Your code layout is nice. Nice to see a good layout of code - even with the Italian comments this is highly understandable.

    Anobium

     

    Last edit: Anobium 2016-11-13
  • Hugh Considine

    Hugh Considine - 2016-11-13

    You can store data in EEPROM using a data table - add "store data" to the end of the table definition. Here is a small example:

    #chip 12F629
    
    Loc = 3
    ReadTable TestTable, Loc, Temp
    
    Table TestTable Store Data
    2
    4
    6
    8
    10
    End Table
    

    This example will load the third item from the table (6) into the variable Temp. The ReadTable command must have a variable for the location to do this - if we wrote "ReadTable TestTable, 3, Temp" the compiler would replace that with "Temp = 6" and would not download the table to the EEPROM.

    Hopefully that helps!

     
  • Gigi

    Gigi - 2016-11-13

    It does not seem right to own the ASM code, since it does not load the W register the value that is in the last byte of memory. If you look at it datasheet says to do a call on this address:

    A calibration instruction is programmed into the last
    location of program memory. This instruction is a
    RETLW XX,
    where the literal is the calibration value.
    The literal is placed in the OSCCAL register to set the
    calibration of the internal oscillator. Example 9-1
    demonstrates how to calibrate the internal oscillator.

    EXAMPLE 9-1: CALIBRATING THE
    INTERNAL OSCILLATOR

    bsf STATUS, RP0 ;Bank 1
    call 3FFh ;Get the cal value
    movwf OSCCAL ;Calibrate
    bcf STATUS, RP0 ;Bank 0


    I just can also testing a pic, I thank the great willingness to improve this compiler open to all.

     
    • Anobium

      Anobium - 2016-11-13

      Test a pic please.

       
  • William Roth

    William Roth - 2016-11-14

    We fixed this on baseline chips, however 4 chips slipped through the cracks, These are:

    12f629, 12f675, 16f630, 16f676

    These chips do not automatically execute MOVLW xx upon reset like the baseline models, Therefore code must call the last address which is a RETLW xx where xx is the calibration data byte.

    The last address on these chips is 0x3ff.

    As a work around try adding the following as the first lines in BASIC source code.

    call 0x3ff
    movwf OSCCAL
    

    The chips noted above are family 14 where the baseline are family 12. It should be possible to modity system.h initsys

    The system.h as been updated to support the chips noted above. Download this file to replace your existing system.h, then test. Let us know the result as I have none of these chips to test.

    https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/include/lowlevel/system.h

     

    Last edit: William Roth 2016-11-14
  • CDRIVE

    CDRIVE - 2016-11-14

    As a GCB forum nube I'm curious. When file updates / fixes like this (system.h) occur do email alerts get sent to alert the membership of the changes?

    Regarding "Block Commenting":
    I too would like to see block commenting. It would also be much more convenient to put commenting options in the mouse right click menue. This will also make block commenting and un-commenting easy by just selecting sequential lines.

    I'm also curious... What language is GCB developed in?

    Thanks,
    Chris

     
    • Anobium

      Anobium - 2016-11-14

      Great questions.

      1. Updates to Great Cow BASIC come via the releases we publish.
      2. The smaller patches will be provided to resolve specific issues and we may decide to publish the URL to the new patch or we may decide to only provide the URL to specific users. But, we always wrap up all the changes into the releases we publish.
      3. If we patch the compiler, we typically send a download URL to the specific user. Again, we always wrap up all the changes into the releases we publish.
      4. Regarding "Block Commenting" we are not the design authority. So, I think these good thoughts need to be addressed to the developers of the SynWrite application which the IDE is based upon.
      5. What language is GCB developed in? Freebasic

      Hope this helps.

       
      • Anobium

        Anobium - 2016-11-14

        And,

        1. Help. I will update the online Help when I get updates to the Help files. I may, if I remember, post the updated Help to the web site. But, we always wrap up all the changes into the releases we publish.
        2. Demos. I do update the Demos when there is something interesting available. But, we always wrap up all the changes into the releases we publish.
        3. Hot Releases. These are the releases I publish as we prepare for the next release. I have a trusted set of developer users that test functionality, edit the Help, create/edit Demos etc. etc. I publish Hot Releases via the Developer Forum. This forum is not avaliable unless you are classified as a Developer. Hot Releases, the early ones, are a tad painful. Things break and I often change daily - so, there is work to be done tidying up your local system to ensure you get clean installs. But, as always.... Hot Releases become releases then I wrap up all the changes and publish.

        Also, a lot of the processes to release are automated. But, there is a lot of work managing and the co-ordinating activities. We make mistakes - we learn and get better all the time - but, we do make mistakes. Be patience. :-)

         
    • Chris Roper

      Chris Roper - 2016-11-14

      Regarding "Block Commenting":
      I too would like to see block commenting.

      Block Commenting has always been a part of SynWrite (The GCBasic IDE) but for some reason unbeknown to the GCBasic Team the SynWrite Team renamed it in the latest release.

      Select the Block of text that you wish to Comment / Uncomment and press:

      CTRL+ALT+/

      Or the MENU sequence:

      Edit->Comments->Toggle Line Comment

      Cheers (the other)
      Chris

       
  • Anobium

    Anobium - 2016-11-14

    Here is the link... http://synwrite.sourceforge.net/forums/

    When it is update... can someone check out that all the existing IDE functionality still works. :-)

     
  • CDRIVE

    CDRIVE - 2016-11-14

    Chris, thanks for the tip! That will do just fine.

    Anobium, thanks for the updates info and the link to the synwrite forum.

    Chris

     
  • Gigi

    Gigi - 2016-11-15

    Anobium & William Roth,
    thanks for having solved this little OSCAL problem only affects some of the old PIC12F but that I use with satisfaction, even look forward to the possibility of storing in EEPROM few bytes without having to create a table is really useful and possible in all compilers.
    Gigi

     
    • Anobium

      Anobium - 2016-11-15

      Good to hear that William's fix works.

       
  • kent_twt4

    kent_twt4 - 2016-11-16

    The eeprom data can be handled without a table, but there are hoops to jump through! For less than $0.10 a much newer device with more program memory and peripherals can be had, making this excercise un-necessary.

    For the hoop jumpers low on program memory. The premise is to use MPASM as a go between the GCBasic compiler and SYNWrite IDE, and the MPLAPX IDE.

    The MPASM assembler option was used by revising the G+STools/MakeHex.bat file. The inbuilt GCASM would also probably work without this step, but that is not the way the proof of concept was tested.

    REM gcbasic.exe /NP /K:A /A:GCASM %1
    gcbasic.exe /NP /K:A /C:\progra~1\microc~1\mpasms~1\MPASMWIN /c- /o- /q+ /l- /x- /w1 %1
    

    After the GCBasic program was compiled, the .asm file was imported into the newly created MPLABX project as a source file. The .asm file was opened then appended for the eeprom data. The eeprom data will be inserted into the MPLABX hex file after a Clean and Build of the project.

    Right click the project, properties, mpasm, and make sure the case sensitive box is unchecked, prior to build.

    ;Set up the assembler options (Chip type, clock source, other bits and pieces)
     LIST p=12F683, r=DEC
    #include <P12F683.inc>
        ORG 0x2100
        DE  0xAA,0xBB,0xCC,0xDD
     __CONFIG _MCLRE_OFF & _WDTE_OFF & _INTRC_OSC_NOCLKOUT
    

    Import the MPLABX .hex file to the programmer and write. Bingo, there is the eeprom data in the PK2 eeprom window. Pic 18's and other devices could have a different eeprom start point, see the MPASM assembler pdf.

     

Log in to post a comment.