Menu

Errormessage compiling for AtTiny

2024-01-16
2024-02-04
  • Frank Steinberg

    Frank Steinberg - 2024-01-16

    Hi All!

    If I try to compile code for ATTiny I get this errormessage:

    timer.h ** (412): Error: IFDEF/Constant: PS_1_8 equates to 4 cannot reassigned to equate to 2 (System Include)
    timer.h ** (413): Error: IFDEF/Constant: PS_1_64 equates to 7 cannot reassigned to equate to 3 (System Include)
    timer.h ** (414): Error: IFDEF/Constant: PS_1_256 equates to 9 cannot reassigned to equate to 4 (System Include)
    timer.h ** (415): Error: IFDEF/Constant: PS_1_1024 equates to 11 cannot reassigned to equate to 5 (System Include)
    

    Reason is in timer.h. The script commands, that should overwrite the prescaler contants in case of existance of a register named TCNT1 (that indicates the different timer1 in an attiny) does not work anymore.

    Since the bug is introduced 27/11/23 the workaround is to remove "#ifdef AVR ... #endif" around the #defines for the standard prescalers.

    Regarding this bug, I found two issues:
    1. Scripts should be the highest priority, but can not overwrite constant-values that are #defined inside a #ifdef block.
    2. The conditions inside a #script are different if a separation-blank is used: "if var(TCNT1) then" works as expected; "if var (TCNT1) then" never gets true (note the blank after "var") .

    I added a revised timer.h. In this library I have also adapted the prescaler for AVR Timer 2 (the old state was "needs work").

    Frank

     
  • Anobium

    Anobium - 2024-02-04

    I will move to released code.

    Re the comments.

    1. IFDEFs need to check the Constant does not exist. There is now a precedence and the scripts do have the priority. The changes in precedence were needed to properly support real conditional compilation.
    2. Re the VAR[SPACE] issue. That is a bug and I will resolve.
     
  • Anobium

    Anobium - 2024-02-04

    Here is test program I have used to fix the script with space issue.

    The next build will have this fix.

    #chip mega328p
    
    #define TestConstant1
    #define TestConstant2 2
    
    portc = TestConstant2
    
    do    
    loop
    
    
        #script
    
            warning TestConstant1
            warning TestConstant2 " =  2"
    
            if DEF(TestConstant1) Then
                warning "Def(TestConstant1) test 1"
            end if
            if DEF (TestConstant1) Then     'with space
                warning "Def (TestConstant1) test 2"
            end if
            if DEF(TestConstant2) Then
                warning "Def(TestConstant2) test 3"
            end if
            if DEF (TestConstant2) Then     'with space
                warning "Def (TestConstant2) test 4"
            end if
    
            if Var(TestConstant2) =  "2" Then
                warning "Var(TestConstant2) test 5"
            end if
            if Var (TestConstant2) =  "2" Then     'with space
                warning "Var(TestConstant2) test 6"
            end if
            if var    (PORTC) Then                  'with spaces
                warning "PORTC Exists"
            end if
            if novar (PORTG) Then                      'with space
                warning "PORTG does not Exists"
            end if
    
        #endscript
    
     

Log in to post a comment.