News:

Let's find out together what makes a PIC Tick!

Main Menu

Fonts In includes and forcing to below code space

Started by TimB, May 07, 2023, 04:44 PM

Previous topic - Next topic

TimB


Hi

In my code I'm using graphic fonts and images. I think you should push fonts etc to after the normal code to prevent issues.
But I'm trying to be good and use includes and they will include the fonts and graphics etc

Is there a way to force the font etc data below the code?

I'm using Cdata for the graphics etc

Screen1:
CData $00,$00,$00,$00,$00,$00,$C0,$F0,_
      $FC,$F0,$C0,$00,$00,$00,$00,$00,_
      $00,$00,$00,$00,$00,$00,_ ' Y_Bytes 0

RGV250

Hi Tim,
What happens if you place the INC at the end of the code.

Bob

TimB


Thanks Bob

That's what I have done in the end. I placed my Graphics sub at the bottom.

JonW

Trastikata helped me with locating data tables at any point in code space with this code.  Save it for future use

'------------------------------------------------------------------------------------------------
'                                  FIXED MEMORY TABLES
'------------------------------------------------------------------------------------------------

Asm-
    DATA_OFFSET Set $
EndAsm

Asm-
    Org 10000
TABLE_1:
    dw 1111,2222,3333,4444,5555,6666,7777

    Org 12000
TABLE_2:
    dw 0,0,0,0,0,0,0

EndAsm

Asm-
    Org DATA_OFFSET
EndAsm

TimB


Thanks

Very neat but it would require too much work altering the data to the right format. Placing the GLCD Routine inc and data etc at the end my main prog seems to be ok so far.

top204

#5
Use Dim As FlashX for the flash memory tables Tim, where FlashX is the Flash8 directive for 8-bit table values.

The compiler automatically places the data in low memory before the user program starts, or above the program with 14-bit core devices to try and minimise page bank switching.

The CData directive is a bit out-dated now for 18F, enhanced 14-bit core, PIC24 and dsPIC33 devices, and was originally added to the compilers a long, long time ago to give a good method of using the flash memory for table data storage. It still has its place every now and then, but the Dim As FlashX for tables should now be classed as normal, because the compiler automatically sorts out where they are placed, and places them out of the way of the program so there is no need to jump over them wherever they are placed in the BASIC listing, or worry about flash memory access above 64K, as long as the table data itself is not larger than 64K. This also saves both time and code space because the TBLPTRU SFR does not need to be constantly manipulated.

TimB


Unfortunately it seems you cannot just replace Cdata with Dim as Flash8. It seems to be more for storing strings.

It would require a complete change to the format of the data to make that work.

Thanks


TimB

Ok I did some more searching and I had the format wrong

Dim SineTable As Flash8 = {$80, $83, $86, $89, $8C, $8F, $92, $95,
                               $98, $9C, $9F, $A2, $A5, $A8, $AB, $AE} 

top204

#8
The, quite new, Dim As FlashX directives can be used for both standard data or string data. For example, the line of code you started the thread with can be written as:

    Dim Screen1 As Flash8 = $00,$00,$00,$00,$00,$00,$C0,$F0,_
                            $FC,$F0,$C0,$00,$00,$00,$00,$00,_
                            $00,$00,$00,$00,$00,$00            ' Y_Bytes 0

Or

    Dim Screen1 As Flash8 = {$00,$00,$00,$00,$00,$00,$C0,$F0,
                             $FC,$F0,$C0,$00,$00,$00,$00,$00,
                             $00,$00,$00,$00,$00,$00}             ' Y_Bytes 0

The flash memory data will be placed before the users program starts, to keep it low in flash. If you view the assembler code from the IDE (F2 button), you will see the data laid out in it:

;---------------------------------------------
; USER. FLASH MEMORY TABLE DATA
Screen1
    db 0,0,0,0
    db 0,0,192,240
    db 252,240,192,0
    db 0,0,0,0
    db 0,0,0,0
    db 0,0
_compiler_main_start_
    movlb 0

But you can also have:
    Dim MyFlString As Flash8 = {"Hello ",
                                "World"}

Then the assembler code is:
;---------------------------------------------
; USER. FLASH MEMORY TABLE DATA
MyFlString
    db 72,101,108,108
    db 111,32,87,111
    db 114,108,100
_compiler_main_start_
    movlb 0



TimB


Thanks Les

What I have done now is convert my standard CData tables used for images to Flash8. However Fonts will present a big issue as there are so many Cdata tables linked with the address then you need the lookup table.

Too much work  :(

BTW  The Data tables are still in the middle of the code. But it matters not.