Menu

Error: Program is too large, cannot fit all subroutines into available program memory

jackjames
2019-11-03
2019-11-04
  • jackjames

    jackjames - 2019-11-03

    RESOLVED: Use GCB ADC Optimisation to reduce code generated


    I needed to check a program written and compiled with a previous version of the compiler (0.98.04 2018-10-20) which did not cause any problems during compilation.
    I recompiled the same source with the latest version but it gave me an insufficient memory problem.
    Not bad because I installed and recompiled with the old compiler, but I preferred to report the problem.

    13:22:03 G+Stool started with parameter 'hex' -> processing C:\programmi\GCB@Syn\G+Stools\makeHEX.bat
    Source-File = H:\Sorgenti Programmi Microcontrollori\Sorgenti programmi GCBASIC\Controllo fancoil (prova)\ControlloFanCoil_LCD_16F1847_DS3231_vers2d_OK.gcb
    Target-File = H:\Sorgenti Programmi Microcontrollori\Sorgenti programmi GCBASIC\Controllo fancoil (prova)\ControlloFanCoil_LCD_16F1847_DS3231_vers2d_OK.hex
    Compiler Version (YYYY-MM-DD): 0.98.04 2018-10-20 (Windows 32 bit) Program Memory: 8021/8192 words (97,91%) RAM: 313/1024 bytes (30,57%) Chip: 16F1847
    Duration: 11.8 Seconds.

    13:31:03 G+Stool started with parameter 'hex' -> processing C:\programmi(x86)\GCB@Syn\G+Stools\makeHEX.bat
    Source-File = W:\Sorgenti Programmi Microcontrollori\Sorgenti programmi GCBASIC\Controllo fancoil (prova)\ControlloFanCoil_LCD_16F1847_DS3231_vers2d_OK.gcb

    WARNINGs / ERRORs reported by Great Cow BASIC (if Syntax Error, doubleclick on the errormessage below) <<<
    Error: Program is too large, cannot fit all subroutines into available program memory
    Duration: 19.4 Seconds.

     

    Last edit: Anobium 2019-11-04
  • Anobium

    Anobium - 2019-11-03

    Can you post the code?

     
  • jackjames

    jackjames - 2019-11-03

    OK.
    The code is large...

     
  • Anobium

    Anobium - 2019-11-03

    Code does not compile following errors.

    You are missing include statement?

    ControlloFanCoil_LCD_16F1847_DS3231_vers2d_OK.gcb (889): Error: Syntax Error
    ControlloFanCoil_LCD_16F1847_DS3231_vers2d_OK.gcb (1722): Error: Syntax Error
    ControlloFanCoil_LCD_16F1847_DS3231_vers2d_OK.gcb (1857): Error: Syntax Error
    ControlloFanCoil_LCD_16F1847_DS3231_vers2d_OK.gcb (1858): Error: Syntax Error
    ControlloFanCoil_LCD_16F1847_DS3231_vers2d_OK.gcb (1859): Error: Syntax Error
    ControlloFanCoil_LCD_16F1847_DS3231_vers2d_OK.gcb (1860): Error: Syntax Error
    

    The above error relates to the following code segements, respectively.

    DS3231_ReadTime (Ora, Minuti, Secondi, Tmp)
    DS3231_EnableOscillator (1)  ' Abilita oscillatore
    DS3231_EnableSQW             ' Uscita 1Hz
    DS3231_SetHourMode (24)      ' 24 ore
    DS3231_SetSQW (0)            ' Abilita uscita 1Hz
    

    To get it to compile I had to place your .h file in my include folder and change the code as follows:

    ...
    #Include <18B20Multi.h>
    
    #IfDef S_DS18B20
       #Include <comandi_mia_codifica.h>
    #EndIf
    ....
    
    '       - Definizone dei Comandi riconosciuti
    #Include <comandi_mia_codifica.h>
    ....
    

    So, I can give you any advice as this has not compiled with these errors.

     
  • jackjames

    jackjames - 2019-11-03

    Thank you for your help.
    I realized that the "ds3231.h" was not included in the compressed file I had attached.
    Unfortunately, in compiling, even following your advice, I always get
    "Error: Program is too large, cannot fit all subroutines into available program memory".
    With the compiler version 0.98.04 this instead does not happen and the program is compiled without problems.
    I enclose an archive containing all the files involved in the compilation, just unpack it in a folder and start the compilation from there ...

     
  • Anobium

    Anobium - 2019-11-03

    Not sure of the root cause, but, I would be using 98.06.

    To resolve this do the following: Simply add the optimisation code

    ''' GCB Optimisation file
    
    'Optmise PWM.h
        #define USE_HPWMCCP1 TRUE
        #define USE_HPWMCCP2 TRUE
        #define USE_HPWMCCP3 TRUE
        #define USE_HPWMCCP4 TRUE
        #define USE_HPWMCCP5 TRUE
    
        #define USE_HPWM1 TRUE
        #define USE_HPWM2 TRUE
        #define USE_HPWM3 TRUE
        #define USE_HPWM4 TRUE
        #define USE_HPWM5 TRUE
        #define USE_HPWM6 TRUE
        #define USE_HPWM7 TRUE
        #define USE_HPWM8 TRUE
    
        #define USE_HPWM_TIMER2 TRUE
        #define USE_HPWM_TIMER4 TRUE
        #define USE_HPWM_TIMER6 TRUE
    
    'Optimise A-d.h
      'Standard family chips
        #define USE_AD0 True
        #define USE_AD1 False
        #define USE_AD2 False
        #define USE_AD2 False
        #define USE_AD3 False
        #define USE_AD4 False
        #define USE_AD5 True
        #define USE_AD6 True
        #define USE_AD7 False
        #define USE_AD8 False
        #define USE_AD9 False
        #define USE_AD10 False
        #define USE_AD11 False
        #define USE_AD12 False
        #define USE_AD13 False
        #define USE_AD14 False
        #define USE_AD15 False
        #define USE_AD16 False
        #define USE_AD17 False
        #define USE_AD18 False
        #define USE_AD19 False
        #define USE_AD20 False
        #define USE_AD21 False
        #define USE_AD22 False
        #define USE_AD23 False
        #define USE_AD24 False
        #define USE_AD25 False
        #define USE_AD26 False
        #define USE_AD27 False
        #define USE_AD28 False
        #define USE_AD29 False
        #define USE_AD30 False
        #define USE_AD31 False
        #define USE_AD32 False
        #define USE_AD33 False
        #define USE_AD34 False
    
        'Family of chips based on 16f1688x with ADCON3 register
        #define USE_ADA0 False
        #define USE_ADA1 False
        #define USE_ADA2 False
        #define USE_ADA3 False
        #define USE_ADA4 False
        #define USE_ADA5 False
        #define USE_ADA6 False
        #define USE_ADA7 False
        #define USE_ADB0 False
        #define USE_ADB1 False
        #define USE_ADB2 False
        #define USE_ADB3 False
        #define USE_ADB4 False
        #define USE_ADB5 False
        #define USE_ADB6 False
        #define USE_ADB7 False
        #define USE_ADC0 False
        #define USE_ADC1 False
        #define USE_ADC2 False
        #define USE_ADC3 False
        #define USE_ADC4 False
        #define USE_ADC5 False
        #define USE_ADC6 False
        #define USE_ADC7 False
        #define USE_ADD0 False
        #define USE_ADD1 False
        #define USE_ADD2 False
        #define USE_ADD3 False
        #define USE_ADD4 False
        #define USE_ADD5 False
        #define USE_ADD6 False
        #define USE_ADD7 False
        #define USE_ADE0 False
        #define USE_ADE1 False
        #define USE_ADE2 False
    

    Compiler Version (YYYY-MM-DD): 0.98.<<>> 2019-11-02 (Windows 32 bit) Program Memory: 7946/8192 words (97.0%) RAM: 310/1024 bytes (30.27%) OSC: , 32 Chip: 16F1847

    And, I spotted this ERROR. The port assignment are incorrect. I have not checked the datasheet but I thiknk AN0 is the first one... and the others are ANx :-)

            #Define PIN_TASTIERA  PORTA.0       ' AN0 Tastiera 6 tasti
            #Define P_TEMP_ARIA   PORTB.7       ' AN6 Sensore lettura temperatura Aria
            #Define P_TEMP_ACQUA  PORTB.6       ' AN5 Sensore lettura temperatura Acqua
    
     
  • Anobium

    Anobium - 2019-11-03

    I have looked the root cause. The compiler improvements in the later version improves banksel selection and this adds just enough banksels to max the chip out.

    The following code cannot be automatically place. 24 words...In the context of the improved stability.

    ;Subs that could not be automatically placed
    ;It may be possible to manually locate them, but you should upgrade to a larger chip if possible
    
    DSP_SIMBOLI
    ;This sub size:4
        call    DSP_LAMPA
        call    DSP_ANTENNA
        call    DSP_MOT
        goto    DSP_SOLE
    
    ;********************************************************************************
    
    LCDWRITECHAR
    ;This sub size:7
        banksel SYSLCDTEMP
        bsf SYSLCDTEMP,1
        banksel LCDCHAR
        movf    LCDCHAR,W
        movwf   LCDBYTE
        pagesel LCDNORMALWRITEBYTE
        goto    LCDNORMALWRITEBYTE
    
    ;********************************************************************************
    
    SYSCOMPEQUAL
    ;This sub size:6
        clrf    SYSBYTETEMPX
        movf    SYSBYTETEMPA, W
        subwf   SYSBYTETEMPB, W
        btfsc   STATUS, Z
        comf    SYSBYTETEMPX,F
        return
    
    ;********************************************************************************
    
    SYSCOMPLESSTHAN
    ;This sub size:7
        clrf    SYSBYTETEMPX
        bsf STATUS, C
        movf    SYSBYTETEMPB, W
        subwf   SYSBYTETEMPA, W
        btfss   STATUS, C
        comf    SYSBYTETEMPX,F
        return
    
    ;********************************************************************************
    
    
     END
    

    So, use OPTIMISATION and change the chip

    Evan

     
  • jackjames

    jackjames - 2019-11-03

    Thanks

     
  • jackjames

    jackjames - 2019-11-03

    Then,
    I have included the optimization file (OPTIMISATION.H) I have not received errors and it has been compiled correctly.
    Regarding these lines:

            #Define PIN_TASTIERA PORTA.0       ' AN0 Tastiera 6 tasti
            #Define P_TEMP_ARIA  AN6 'PORTB.7  ' AN6 Sensore temperatura Aria
            #Define P_TEMP_ACQUA AN5 'PORTB.6  ' AN5 Sensore temperatura Acqua
    

    If I use AN0 ... AN6 I have the following error that does not occur with version 0.98.04:
    ControlloFanCoil_LCD_16F1847_DS3231_vers2d_OK.gcb (299): Error: PORT6 is not a valid I/O pin or port
    ControlloFanCoil_LCD_16F1847_DS3231_vers2d_OK.gcb (300): Error: PORT5 is not
    a valid I/O pin or port

     
  • Anobium

    Anobium - 2019-11-04

    That is correct. You need to resolve the error at the line indicated by the error line.

    Dir PIN_TASTIERA In
    Dir P_TEMP_ARIA  In
    Dir P_TEMP_ACQUA In
    

    The above statements are now ANx values. So, if you want to set the direction of the assiocated ports you need to add some more code.

    '       - Altri pins
            #Define PIN_TASTIERA  AN0  'PORTA.0       ' AN0 Tastiera 6 tasti
            #Define P_TEMP_ARIA   AN6'  PORTB.7       ' AN6 Sensore lettura temperatura Aria
            #Define P_TEMP_ACQUA  AN5'  PORTB.6       ' AN5 Sensore lettura temperatura Acqua
    
            #Define PORT_PIN_TASTIERA  PORTA.0       ' AN0 Tastiera 6 tasti
            #Define PORT_P_TEMP_ARIA   PORTB.7       ' AN6 Sensore lettura temperatura Aria
            #Define PORT_P_TEMP_ACQUA  PORTB.6       ' AN5 Sensore lettura temperatura Acqua
    
    ....
    ....
    ....
    
    '       - Imposta gli ingressi
            Dir PORT_PIN_TASTIERA In
            Dir PORT_P_TEMP_ARIA  In
            Dir PORT_P_TEMP_ACQUA In
    '       -
    

    And, if I may advise. I would get off the chip you are using asap. As an architecture the 1847 is a dead end - 18 pin products are very very rare. 16F18855 series would be better

    Enjoy,

    Evan

     
  • jackjames

    jackjames - 2019-11-04

    Thanks for your help.
    For the moment I have solved the problem.
    Certainly it is better to switch to another one, but of PIC16F1847 I have a certain number and I am sorry to leave them unused.

     
  • Anobium

    Anobium - 2019-11-04

    I would bin them, they have so many constraints for you.

    Anyway, you are up and running.

    Enjoy.

     

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.