Menu

AVR compiler does not work

AVR
2020-08-27
2020-09-10
1 2 > >> (Page 1 of 2)
  • AVR

    AVR - 2020-08-27

    I cannot make relatively simple code to work. I get "out of registers" errors all the time.

    #chip TINY102
    
    Dim Ledbank as word alias portb, portc
    Dim Adcval As word
    
    
    'Ensemble LEDs
    Ledbank = 0
    wait 1 ms
    
    'Lire la tension
    adcval = readad10 ( an0 )
    Ledbank = Ledbank * 2
    Ledbank = Ledbank or 1
    

    This is using the latest code from Sourceforge compiles up as 0.98.<<>> 2020-08-07.

    Is this just broken ?

    Patrick

    Pardon. Modifie pour corriger la mise en page de la post.

     

    Last edit: AVR 2020-08-27
  • kent_twt4

    kent_twt4 - 2020-08-27

    Indeed, GCB creates too many SYSTEMP type variables. Anobium has done much to make reduced instruction set devices work. Manual manipulation of the registers may be required.

    Not knowing your specific case use for this device, a few suggestions:

    There is no PORTC, it has PORTA and PORTB.

    Re-thinking how you want to display the leds. By discarding the Dim ledbank as Word Alias statement frees up several variables and does compile. Using bit names like PortA.0 = adcval.7 PortA.1=adcval.6 etc. might work?

    The tiny102 only has five effective output pins for leds, PA0, PA1, PB1, PB2, PB3, so this could be handled with ReadAD(ANx).

    P.S. Aside from the cost, 8 pin devices like the tiny13a, 25, 45, 85 have worked well for me.

     

    Last edit: kent_twt4 2020-08-27
  • AVR

    AVR - 2020-08-27

    Thank you.

    The code is just example code to prouver the error. Making program with compiler issue happens with lots of different code for this chip.

    Is the posted AVR code working? Do you try my simple program ?

     
    • AVR

      AVR - 2020-08-27

      I remove the references to the ports. Same error.

      #chip TINY102
      
      Dim mot as word alias haute, faible
      Dim Adcval As word
      
      
      'Ensemble LEDs
      mot = 0
      wait 1 ms
      
      'Lire la tension
      adcval = readad10 ( an0 )
      mot = mot * 2
      mot = mot or 1
      
       
  • kent_twt4

    kent_twt4 - 2020-08-27

    All I can say is the too many register variables error is well known, but the solution is not so simple.

    When developing programs it is always easier to use a much more capable chip in terms of RAM, program data space, and even pins. Then optimize and see if it will fit a smaller and less featured and costly device if desired.

    Your code does not compile.

    Do you have the tiny102? What do you what to do with it? I can test with a tiny104.

     
  • Anobium

    Anobium - 2020-08-27

    @AVR and @kent_twt4

    Sorry but this error is caused by the compiler and we are waiting for Hugh to resolve. See item 12 in post https://sourceforge.net/p/gcbasic/discussion/579125/thread/8aafd62637/#9e23

    Support for AVRrc chips. With Hugh to complete development to handle systempN variables. AVRrc chips are: ATtiny10,ATtiny20,ATtiny4,ATtiny40.ATtiny5,ATtiny9

    You will have to reduce the code to just simple code for the time being.

     
  • AVR

    AVR - 2020-08-27

    This will resolved when?

     
  • Kato

    Kato - 2020-08-27

    I have same issue. Any fix available? The seems to happen at random and it very hard to workaround.

    Please sort.

     
  • kent_twt4

    kent_twt4 - 2020-08-27

    Somtimes there is a workaround.

    Tested and working on tiny104 using tiny102 pinouts. Uses upper nibble of the adcval.

    You will need the extra effort to provide the solution :-) with the tiny10 type reduced instruction set devices.

    'The TPIDATA/ADC (PA0) and TPICLK (PA1) pins
    'have to be "lifted" to program the chip
    
    #chip TINY104,1
    #option explicit
    
    Dim adcval As Byte
    
    'led display used common anode config
    PortB = 0b1110
    PortA.1 = 1
    
    Main:
      adcval = ReadAD(AN0)
      'PortA.0 is adc reading
      'PortA.2 is RESET
      adcval = adcval & 0b11110000
      PortB.3 = !adcval.7
      PortB.2 = !adcval.6
      PortB.1 = !adcval.5
      PortA.1 = !adcval.4
      wait 5 ms
    goto Main
    

    EDITS: sorry multiple edits, had to make comments on display type and program pins to clarify

     

    Last edit: kent_twt4 2020-08-27
  • kent_twt4

    kent_twt4 - 2020-08-27

    Slightly optimized.

    #chip TINY104,1
    #option explicit
    
    Dim adcval As Byte
    
    'led display used common anode config
    PortB = 0b1110
    PortA.1 = 1
    
    Main:
      adcval = ReadAD(AN0)
      'PortA.0 is adc reading
      'PortA.2 is RESET
      adcval = !adcval & 0b11110000
      PortB.3 = adcval.7
      PortB.2 = adcval.6
      PortB.1 = adcval.5
      PortA.1 = adcval.4
      wait 5 ms
    goto Main
    
     
  • Kato

    Kato - 2020-08-27

    Kent thanks - too hard

     
  • kent_twt4

    kent_twt4 - 2020-08-27

    Should not be too hard. The tiny102 is capable of basic operations.

    @AVR and @Kato, until a use case is stated, like for example "I want to control motor operation, or speed, with a potentiometer or joystick", OR I want to port PicAxe code, I and others will have a hard time helping.

     
  • Kato

    Kato - 2020-08-28

    My point is - the compiler does not work. Basic operations that are only a few lines long do not work.

    Be best to add something an error message that means something to a normal person. I spent hours before giving up.

     
  • Anobium

    Anobium - 2020-08-28

    Please wait for an update, I will ask Hugh to look at the core issue.

    Meanwhile, I understand the fustration but if the error happens you need to simplify your code. Less use of WORDs variable, no use of AND/OR etc (use oher methods), and, use in-build timer rather than WAIT.

    Also, see the demos - they may help https://github.com/Anobium/Great-Cow-BASIC-Demonstration-Sources/tree/master/ChipFamily121_AVRrc_Specific_Solutions

    The compiler code for these specific chips is NOT completed and we need your help and patience.

     
  • Anobium

    Anobium - 2020-08-28

    @AVR and @KATO. I have sent you a PM with the URL to the latest Release Candidate software. This does not resolve the issues you have but it ensures that your complete installation is the most up to date.

     
  • Kato

    Kato - 2020-08-30

    Thank you.

    My simple exampke program works with other chips but not these chips. So, it looks like a huge bug to me.

    @w_cholmondeley Question is. When will this be fixed? Or, when will you delete the chipfiles to stop this from happening to others?

     
    • mkstevo

      mkstevo - 2020-09-01

      There is a danger that people forget that Great Cow Basic is very generously written and maintained at no cost to the end user.

      If this was commercial software, sold on the basis that it did work with these specific devices, you might be justified in expecting a swift resolution. As it is provided entirely free of charge and with known limitations for the devices being used, suggesting that a different device is selected is a sensible path forward

       
      • Anobium

        Anobium - 2020-09-01

        @mkstevo - thanks for the support.

        In hindsight I should have made this issue clear when a user used the updated compiler. A few more moments of thought when we were adding the new capability and we could have added compiler messages to inform. Will do this in the future :-)

         
  • kent_twt4

    kent_twt4 - 2020-08-30

    No, do not delete the chip files. They are fully functional for these resource limited chips. Just like the PIC 10f series chips, the tiny10 family have entered the manual register manipulation and assembly instructions Zone.

    Even if more RAM becomes available thru optimization, people could be sorely disappointed with the 256 or 512 word data program size.

    The tiny10 family will never live up to do all devices like the m328p. Not enough on chip periperals at hand. But no one should not be denied to develop, even if GCB commands and libraries will be limited.

    If I were to have stopped a project after only a few hours, do to some roadblock; many, many would never have seen completion.

    Perhaps a warning in the output window? that one is dealing with limited capability device. And/Or, refer to link explaining the device family limitations?

    My $0.02

     
    • Anobium

      Anobium - 2020-08-31

      @kent_twt4

      Agree with your post.

      We can do the warning (see below) and I will write a limitations document but the point as initially posted. Simple Great Cow BASIC source code should sort of work


      I could change the error message to more frank. Only for these chips.

      Error: Out of registers. Please break up any complex calculations
      to

      Error: Out of registers. This specific microcontroller has limited registers. Please use BYTE variables where ever possible, do not use logic (OR/AND etc) on anything but BYTE variables, use ROTATE rather than mutliplication. Essentially keep the code very simple.

       
      • kent_twt4

        kent_twt4 - 2020-09-01

        Yes, that looks good.

         
        • Anobium

          Anobium - 2020-09-06

          Revised and commited as follows:

          "..\GCB@Syn\GreatCowBASIC\demos\chipfamily121_avrrc_specific_solutions\tiny102_104\tiny104_readanologue_to_setpwmduty\readanologue_to_setpwmduty_bug.gcb"
          
          Error: Out of registers. This specific AVRrc microcontroller has limited registers. Please use BYTE variables where ever possible, do not use logic (OR/AND etc) on anything but BYTE varia
          bles, use ROTATE rather than mutliplication. Essentially keep the code very simple.
          

          :-)

           
  • Anobium

    Anobium - 2020-08-31

    Let us see if we can resolve the real issue. The compiler is capable of managing the variables for the core operations.

    I have asked Hugh, previously, to have to look at the issue.

    Evan

     
  • stan cartwright

    stan cartwright - 2020-08-31

    Why not use like a 08 picaxe chip and use peek and poke. Data sheet says 32 bytes ram,
    program memory 1K

     
    • Anobium

      Anobium - 2020-08-31

      Stan... these are the low level compiler management of the system variables. These chip are very very different from any PIC chip.

       
1 2 > >> (Page 1 of 2)

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.