Announcement

Collapse
No announcement yet.

Need more flash memory space to save program

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need more flash memory space to save program

    Diablo 16 processor has a total user flash 6x32kb=192kb, but why workshop 4 only allow access to a maximum of 32kb user flash? I need more memory space to save program, how to solve that problem? Thank you.

  • #2
    You can only access 32kb at one time.
    To access beyond that you use a banking scheme.
    You can do all sorts of bank manipulations, have a look at the flash_* commands in the manual.
    There are examples of most commands in the File, Samples, Diablo Designer folder
    Mark

    Comment


    • #3
      Thanks for prompt response. Is this scenario possible: I save all functions into another bank (eg BANK1), and call that functions from the main (bank0)?

      Comment


      • #4
        Sure, you just need to ensure that you pass pointers to required variables to BANK1
        Mark

        Comment


        • #5
          How to solve this problem?

          // All functions stored in bank1
          Code:
          #platform "uLCD-43DT"
          #MODE FLASHBANK_1  
                                  
          func add(var a, var b)
              return a + b;
          endfunc
          
          func sub(var a, var b)
              return a + b;
          endfunc
          
          func main()
              gfx_ScreenMode(LANDSCAPE);
              flash_EraseBank(FLASHBANK_1, 0xDEAD);
          endfunc

          // Main program (call functions in bank1)
          Code:
          #platform "uLCD-43DT"
          #MODE FLASHBANK_0  
          
          func main()    
              gfx_ScreenMode(LANDSCAPE) ;
          
              print([DEC] add(1,2)), "\n");     // call add function in bank1?
              print([DEC] sub(4,3)), "\n");     // call sub function in bank1?
          
              repeat forever
          endfunc

          Comment


          • #6
            Have a look at the FlashExec and FlashCalled examples.
            Mark

            Comment


            • #7
              I change like this but still not working?

              // All functions stored in bank1
              Code:
              #platform "uLCD-43DT"
              #MODE FLASHBANK_1
              
              func add(var a, var b)
                  return a + b;
              endfunc
              
              func sub(var a, var b)
                  return a - b;
              endfunc
              
              func main(var args)
                  gfx_ScreenMode(LANDSCAPE);
                  flash_EraseBank(FLASHBANK_1, 0xDEAD);
              
                  switch(args[0])
                      case 0:
                          return add(args[1], args[2]);
                      case 1:
                          return add(args[1], args[2]);
                  endswitch
              endfunc
              // Main program (call functions in bank1)
              Code:
              #platform "uLCD-43DT"
              #MODE FLASHBANK_0
              
              func main()
                  var args[3];
              
                  gfx_ScreenMode(LANDSCAPE) ;
              
                  args[0]:=0; // function id
                  args[1]:=1; // first params = a
                  args[2]:=2; // second params = b
                  print([DEC] flash_Exec(FLASHBANK_1, args), "\n");     // call to add function in bank1
              
                  args[0]:=1; // function id
                  args[1]:=5; // first params = a
                  args[2]:=2; // second params = b
                  print([DEC] flash_Exec(FLASHBANK_1, args), "\n");     // call to sub function in bank1
              
                  repeat forever
              endfunc

              I have an idea: We can add the name of the bank(eg bank1) in front of the function name, and the compiler automatically save the functions to bank1. It will facilitate users in calling a function in different banks. This will simplify the user if they want to save the function in different banks(eg bank1) and call from main bank(bank0). Is possible?

              Code:
              #MODE FLASHBANK_0
              
              // this function will be saved to bank1 automatically by compiler.
              // If no additional bank names, the automatic function will be saved where the main program is run(eg, bank0 as default).
              bank1 add(var a, var b)
                  return a + b;
              endfunc
              
              // call function in bank1 from bank0
              print([DEC]bank1 add(1,2));
              Last edited by rwin; 18th May 2015, 04:06 PM.

              Comment


              • #8
                No, that wouldn't be possible, the bank is a completely separate program, there is no way for one bank to have 'visibility' of offsets within it.

                As for your code, try this
                Code:
                #platform "uLCD-43DT"
                #MODE FLASHBANK_0
                
                func main()
                    var args[4];
                
                    gfx_ScreenMode(LANDSCAPE) ;
                
                    args[0]:=3; // 3 parameters
                    args[1]:=0; // function id
                    args[2]:=1; // first params = a
                    args[3]:=2; // second params = b
                    print([DEC] flash_Exec(FLASHBANK_1, args), "\n");     // call to add function in bank1
                
                    args[0]:=3; // 3 parameters
                    args[1]:=0; // function id
                    args[2]:=5; // first params = a
                    args[3]:=2; // second params = b
                    print([DEC] flash_Exec(FLASHBANK_1, args), "\n");     // call to sub function in bank1
                
                    repeat forever
                endfunc

                Code:
                #platform "uLCD-43DT"
                #MODE FLASHBANK_1
                
                func add(var a, var b)
                    return a + b;
                endfunc
                
                func sub(var a, var b)
                    return a + b;
                endfunc
                
                func main(var code, var a, var b)
                //    gfx_ScreenMode(LANDSCAPE);
                //    flash_EraseBank(FLASHBANK_1, 0xDEAD);
                
                    switch(code)
                        case 0:
                            return add(a, b);
                        case 1:
                            return add(a, b);
                    endswitch
                endfunc
                You should have been able to work that out pretty quickly yourself with the manual in one hand and using a few print statements for diagnostics in the other
                Mark

                Comment


                • #9
                  @Mark, Thank you. I hope 192Kb flash is available for the future, so that 4D lcd can be used for complex applications.
                  Last edited by rwin; 18th May 2015, 04:48 PM.

                  Comment

                  Working...
                  X