Menu

Compiler Enhancement: Improved USART and LCD setup detection with warnings for users.

Anobium
2022-06-25
2022-06-25
  • Anobium

    Anobium - 2022-06-25

    How many times have you used HSerPrint and you get no output, or, you Print and all you get is a load of unrelated error messages?

    These changes to the compiler will resolve these issues.

    I have added new capabilities to detect missing USART and LCD setup parameters. This is two different solutions but the user experience is really improved!


    LCD Error

    The error was like this ....

    >>>  WARNINGs / ERRORs reported by Great Cow BASIC    <<<
    lcd.h (559): Error: SYSLCDTEMP.0 is not a valid I/O pin or port
    lcd.h (562): Error: SYSLCDTEMP.0 is not a valid I/O pin or port
    lcd.h (563): Error: SYSLCDTEMP.0 is not a valid I/O pin or port
    lcd.h (564): Error: SYSLCDTEMP.0 is not a valid I/O pin or port
    lcd.h (565): Error: SYSLCDTEMP.0 is not a valid I/O pin or port
    lcd.h (566): Error: SYSLCDTEMP.1 is not a valid I/O pin or port
    lcd.h (567): Error: SYSLCDTEMP.0 is not a valid I/O pin or port
    lcd.h (964): Error: SYSLCDTEMP.0 is not a valid I/O pin or port
    lcd.h (1054): Error: SYSLCDTEMP.0 is not a valid I/O pin or port
    lcd.h (1055): Error: SYSLCDTEMP.0 is not a valid I/O pin or port
    lcd.h (1056): Error: SYSLCDTEMP.0 is not a valid I/O pin or port
    lcd.h (1057): Error: SYSLCDTEMP.0 is not a valid I/O pin or port
    

    now

    An error has been found:
    
     Error: LCD Parameters not setup correctly - please correct the LCD setup
    

    At least the user now knows to looks at the LCD setup not wading through LCD.h


    USART

    If you did not define the constant USART_BAUD_RATE you got NOTHING.... no errors, no assembly messages.. just nothing.

    now you get a message telling you to specify the baud rate.

    An error has been found:
    
     Error: USART NOT SETUP CORRECTLY. NO BAUD RATE SPECIFIED - PLEASE CORRECT 
     USART SETUP
    

    Help

    LCD ERROR HANDLING

    The setup of an LCD is inspected and an appropriate error message is displayed. The Compiler now controls error messages when LCD is not setup up correctly. This is hard coded into the compiler (at build 1131 or greater).

    RAISING COMPILER ERROR CONDITIONS

    From build 1131 or greater the compiler now supports raising a compiler error message.

    The method uses the RaiseCompilerError method to pass an error message to the compilation process.

    An example from USART.H/INITUSART subroutine is shown below. This example tests for the existence of one of the three supported baud rate constants. If none of the constants exist and the constant (in this example) STOPCOMPILERERRORHANDLER does not exist the RaiseCompilerError with the string will be passed to the assembler for error processing. This permits the inspect of the user program with appropriate messages to inform the user.

            ....
            #IFNDEF ONEOF(USART_BAUD_RATE,USART1_BAUD_RATE,USART2_BAUD_RATE) THEN
                'Look for one of the baud rates CONSTANTS
                #IFNDEF STOPCOMPILERERRORHANDLER
                  RaiseCompilerError "USART not setup correctly. No baud rate specified - please correct USART setup"
                #ENDIF
              #ENDIF
              .....
    

    The RaiseCompilerError handler can be stopped using the constant STOPCOMPILERERRORHANDLER as shown above.

    The RaiseCompilerError can be used in any library or user program, The syntax is strict (as folllows).

    `
    RaiseCompilerError "String message - with double quotes"

        RaiseCompilerError "%message.dat string%"
    

    `


    Hopefully, these changes will improve the experience of using Great Cow BASIC.

     

    Last edit: Anobium 2022-06-25
  • William Roth

    William Roth - 2022-06-25

    A very nice addition.

    RaiseCompilerError will be quite useful to developers and advanced users. Can be used for error trapping, debugging code, and especially in libraries to check for necessary user defined constants.

    Thanks !

     
    • Anobium

      Anobium - 2022-06-25

      Hopefully, helps everyone.

      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.