2015-08-18 03:41 AM
Guys,
How can I use internal 64Kbytes SRAM from STM32F107? Any code example from StdPeripheral ? Thanks2015-08-18 04:14 AM
Any normal variable you declare will be stored in SRAM automatically.
This'll be in SRAM:u8 myArray[256]; Am I perhaps not understanding what you mean?2015-08-18 04:18 AM
I see, thanks for responding...
how to implement this in code ? I read from datasheet reference :3.3.1 Embedded SRAMThe STM32F10xxx features up to 96 Kbytes of static SRAM. It can be accessed as bytes,
half-words (16 bits) or full words (32 bits). The SRAM start address is 0x2000 0000.
3.3.2 Bit banding
The Cortex®-M3 memory map includes two bit-band regions. These regions map each word
in an alias region of memory to a bit in a bit-band region of memory. Writing to a word in the
alias region has the same effect as a read-modify-write operation on the targeted bit in the
bit-band region.
In the STM32F10xxx both peripheral registers and SRAM are mapped in a bit-band region.
This allows single bit-band write and read operations to be performed. The operations are
only available for Cortex®-M3 accesses, not from other bus masters (e.g. DMA).
A mapping formula shows how to reference each word in the alias region to a corresponding
bit in the bit-band region. The mapping formula is:
bit_word_addr = bit_band_base + (byte_offset x 32) + (bit_number × 4)
where:
bit_word_addr is the address of the word in the alias memory region that maps to the
targeted bit.
bit_band_base is the starting address of the alias region
byte_offset is the number of the byte in the bit-band region that contains the targeted
bit
bit_number is the bit position (0-7) of the targeted bit.
Example:
The following example shows how to map bit 2 of the byte located at SRAM address
0x20000300 in the alias region:
0x22006008 = 0x22000000 + (0x300*32) + (2*4).
Writing to address 0x22006008 has the same effect as a read-modify-write operation on bit
2 of the byte at SRAM address 0x20000300.
Reading address 0x22006008 returns the value (0x01 or 0x00) of bit 2 of the byte at SRAM
address 0x20000300 (0x01: bit set; 0x00: bit reset).
For more information on Bit-Banding, please refer to the Cortex®-M3 Technical Reference
Manual.
2015-08-18 04:28 AM
Still not quite sure what you're worried about?
Are you writing code in assembler or C?2015-08-18 05:20 AM
I'm writing on C,
I want to know the address of the data for reading and writing later on... How can I point to one address and write ? then read ? for example write at the location 0x020000 = ''a''.... then read from that location later on... thanks2015-08-18 05:43 AM
The linker assigns addresses to variables in SRAM. Review the .MAP output to see where they are, and what's being used.
int a = 123;printf(''%p\n'', &a); // Print address of 'a'*((uint32_t *)0x20002000) = 0x12345678;printf(''%08X\n'', *((uint32_t *)0x20002000) );2015-08-18 05:57 AM
Its trivial to write and read variables that are in RAM.
Do you want to write and read random addresses in RAM? If so, what for?2015-08-18 06:17 AM
Thanks clive,
I think I can see how it works from here : STM32F10x_StdPeriph_Lib_V3.5.0/Project/STM32F10x_StdPeriph_Examples/Library_Examples.html how do you reckon ?Bit Banding
This example shows how to use CortexM3 Bit-Band access to perform atomic read-modify-write and read operations on a variable in SRAM.
2015-08-18 07:29 AM
Bit-Banding simply rebases the memory so that each bit is not represented by a 32-bit word.