Hi all
I'm learning to program uC's on by myself, and I'm using the MCB1700, now I have some doubts.
for example, How can I reserve SRAM space memory for storing data? what I want is to have for example 4 KB of memory to store data, from one memory location known and fixed, and no access to it except the data I want to store and read to and from it.
I am currently trying both ways, but I'm not absolutely convinced that this work or playing well, are as follows:
- 4 KB array, starting at position 0x20080000.
Unsigned char my_sram_sector [0x4000] __attribute__ ((section (". ARM.__at_0x20080000"), zero_init));
or
- In Options for Target 'FLASH' in Target tab
in Read/Write Memory Areas
default off-chip Start Size NoInit selected RAM1: 0x2008000 0x4000 Selected Not Selected RAM2: Not Selected RAM3:
default off-chip Start Size NoInit selected IRAM1: 0x10000000 0x8000 Not Selected Not Selected IRAM2: 0x2007C000 0x4000 Not Selected
Could this be a correct way?
And if I want to store in the 4 KB data structures, how could I do it?
thanks in advance and forgive my English
Everything under the Options for Target 'FLASH' in Target tab is used by the linker during 'scatter loading'
If you want a section of memory that would not be used by the linker, gernerally you should not include it under these settings.
(btw. SRAM at this location is generally used for USB and Ethernet peripherals)
In your case just remove the RAM section from this tab all together and use your
or if you just want a pointer this is more portable:
Unsigned char * my_sram_sector = (Unsigned char *)0x20080000;
Hope this helps.
Thanks Marc
I think your comment has been helpful, but ... If I understand correctly.
the three LPC1768 SRAM banks are: On-chip SRAM 0x1000 0000 - 0x1000 7FFF For device with 32 kB of local SRAM. On-chip SRAM (typically Used for peripheral data) 0x2007 C000 - 0x2007 FFFF AHB SRAM - bank 0 (16 kB) 0x2008 0000 - 0x2008 3FFF AHB SRAM - bank 1 (16 kB)
So, if In Options for Target 'FLASH' in Target Tab, I leave this configuration
in Read / Write Memory Areas
default off-chip Start Size NoInit
default on-chip Start Size NoInit selectedI RAM1 0x10000000 0x8000 Not Selected Not Selected IRAM2 0x2007C000 0x4000 Not Selected
both local 32Kb SRAM and 16Kb bank 0 SRAM are treated by the linker, and are sensitive to any local and global variables, and used by the stack and heap. and fully 16Kb bank 1 SRAM would never be used during program execution unless I explicitly choose to access it. That's right?
I do not understand what you mean by the expression (btw. SRAM At This location is Generally Used peripherals for USB and Ethernet)
Do you mean that if my program use USB or Ethernet, I can not use these memory locations to store my data from, and if so ... How I can use this memory and USB or Ethernet at once?
thanks again
Some actions - like DMA transfers - do care about whith memory block you try to use. Another thing is that the different RAM blocks can be accessed concurrently since the processor have more than one bridge. So the peripherials can perform DMA transfers without affecting bandwidth of the main RAM.
Hi,
Most emac driver and usb stacks require buffers. Because these communication are fast it's often a good idea to put these buffers in the SRAM. So for example bank 0 would be for the USB stack and bank 1 for the ethernet driver.
I would store my configuration data in a section of the iRAM myself but there is no rule that says you have too use this setup.
You are correct in your explanation of the linker memory section usage. However the only reason to add a memory section to the target tab is so the linker can use it.
For example I add bank 0 and bank 1 and I change the individual file options for my emac and USB source file to use these locations for RAM.
I'm not sure what you are doing but you may want to consider reserving a section of iRAM that the linker can not use.
TARGET TAB
Then in your code add a block of memory at 0x10006000 for your data.
Thank you everyone, specially Marc
I was quite clear with the explanation you have given me and meets my needs.