Hanski
July 25, 2022, 6:29pm
1
Hi, is there any example how to use “HIGH RAM” for own data? I know I need to say in my_settings.h:
#define PROJ_HIGH_RAM HIGH_RAM_ON
But then what? In which address that is usable? Can I copy data normally using memcpy() between the high ram and the normal ram?
spinal
July 25, 2022, 9:20pm
2
I can’t remember for sure, but if you dig around the Pokittolib source, the music code just uses a pointer to that memory location I think.
spinal
July 26, 2022, 4:14pm
3
Something like this…
unsigned char *myBuffer = (unsigned char *) 0x20000000;
1 Like
I used both in PtaD like so
constexpr uint32_t HIGH_RAM1 = 0x20000000;
constexpr uint32_t HIGH_RAM2 = 0x20004000;
Then its just defining pointers and setting their address to an offset into either HIGH_RAM1 or HIGH_RAM2 like this:
constexpr uint32_t TILEMAPBG_MEMORY_ADDRESS = HIGH_RAM1;
constexpr uint32_t TILEMAPFG_MEMORY_ADDRESS = HIGH_RAM1 + TILEMAP_MEMORY_SIZE;
uint8_t *PTAD::tilemapBG = (uint8_t*)PTAD::TILEMAPBG_MEMORY_ADDRESS;
uint8_t *PTAD::tilemapFG = (uint8_t*)PTAD::TILEMAPFG_MEMORY_ADDRESS;
Here both my background and foreground tilemaps are stored sequentially in HIGH_RAM1.
3 Likes
r043v
August 3, 2022, 6:15pm
5
the ld file contain what you need to declare any var to be into others ram chip :
MEMORY
{
...
Ram1_2 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x800 /* 2K bytes */
Ram2USB_2 (rwx) : ORIGIN = 0x20004000, LENGTH = 0x800 /* 2K bytes */
...
}
...
/* possible MTB section for Ram1_2 */
.mtb_buffer_RAM2 (NOLOAD) :
{...
} > Ram1_2
/* DATA section for Ram1_2 */
.data_RAM2 : ALIGN(4)
{...
} > Ram1_2 AT>MFlash256
/* possible MTB section for Ram2USB_2 */
.mtb_buffer_RAM3 (NOLOAD) :
{...
} > Ram2USB_2
/* DATA section for Ram2USB_2 */
.data_RAM3 : ALIGN(4)
{...
} > Ram2USB_2 AT>MFlash256
so you may check using theses sections for your variables definitions, using gcc attribute section way :
int myvar __attribute__((section (".mysection"))) ;
_ . -
yet for my own projects i wasn’t able to properly use these (as i lack too much about some asm and low level basis like “data” “mtb” “bss” and so lol) so i redeclared sections into my ld file ( gm0/LPC11U68.ld at main · r043v/gm0 · GitHub
MEMORY
{
...
SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x800
USBSRAM (rwx) : ORIGIN = 0x20004000, LENGTH = 0x800
}
...
__top_SRAM = 0x20000000 + 0x800;
__top_USBSRAM = 0x20004000 + 0x800;
...
SECTIONS
{
...
.sram :
{
. = ALIGN(4);
__sram_start__ = .;
*(.sram*)
__sram_end__ = .;
} > SRAM AT>MFlash256
.usbsram :
{
. = ALIGN(4);
__usbsram_start__ = .;
*(.usbsram*)
__usbsram_end__ = .;
} > USBSRAM AT>MFlash256
...
}
and i use them in my code with these :
u8 gfxBank[16*16*4] __attribute__((section (".sram"))) ;
u32 rgfxBank32[16*16] __attribute__((section (".usbsram"))) ;
1 Like