Sram
SRAM is the „Memory“ object of the superior class „Avr“.
Properties (read only) | ||
---|---|---|
Name | Description | Returns |
.StartAddr oder .Addr | Phys. Start address of the available memory. | word |
.endAddr | Phys. End address of the available memory. | word |
.Length | Byte size of the available memory. | word |
.DynAddr | Start address of the available dynamic memory. | word |
.DynLength | Byte size of the available dynamic memory. | word |
.Space | Byte size of the unused dynamic memory. | word |
Methods (call) | ||
Name | Description | |
.ClearAll | Clear usable memory (fill with Null-Bytes).1) | |
.Dump | Hex dump of the whole physicly accessiblememory to the first serial port. 2) | |
.DumpBlocks | Hex dump of all currently allocated Memory Blocks. 3) |
Direct access to SRAM
The direct access to memory is similar to the Object Flash- or eeprom. Gives you „manual“ access to memory. e.g. you have access to Variables and the whole Stack (the whole memory). Write to memory only when you do not use Luna's Memory-Block and String functions, because these function mange memory themselves. Manual memory mangement may make sense on Controller with limited memory.
Methods (read/write) | ||
---|---|---|
Name | Description | Rückgabetyp |
.ByteValue(offset) | Byte read/write | byte |
.WordValue(offset) | Word read/write | word |
.IntegerValue(offset) | Integer read/write | integer |
.LongValue(offset) | Long read/write | long |
.SingleValue(offset) | Single read/write | single |
.StringValue(offset,bytes) | String read/writeincluding Length | string |
.PString(offset) | Pascal-String read/write (Start-Byte is the Length) | string |
.CString(offset) | C-String read/write (Null terminated) | string |
Example 1
print "Sram.startaddr: "+hex(Sram.startaddr) print "Sram.endaddr: "+hex(Sram.endaddr) print "Sram.length: "+str(Sram.length) print "Sram.dynaddr: "+hex(Sram.dynaddr) print "Sram.dynlength: "+str(Sram.dynlength) print "Sram.space: "+str(Sram.space) Sram.ClearAll ' complete erase (fill with Null-Byte)
Example 2:
avr.device = atmega32 avr.clock = 20000000 ' Quartz avr.stack = 32 ' Bytes for Program stack (Default: 16) uart.baud = 19200 ' Baudrate uart.Recv.enable ' activate transmit uart.Send.enable ' activate receive dim a,b,i,j as byte dim offset as word dim s as string print 12;"*********************************************" print "* sram direct access" print a=&h11 b=&h22 s="hello" print print "**** Sram dump from variable space to end of RAM ***" print "sram.Addr = 0x";hex(sram.Addr) print "sram.StartAddr = 0x";hex(sram.StartAddr) print "sram.endAddr = 0x";hex(sram.endAddr) print "sram.Length = ";str(sram.Length) print offset = 0 do print "0x";hex(word(sram.Addr+offset));": "; for i=0 to 23 when offset > sram.length do exit print hex(sram.ByteValue(offset));" "; incr offset next sub offset,24 print " "; for i=0 to 23 when offset > sram.length do exit a=sram.ByteValue(offset) if a>31 then print a; else print "."; end if incr offset next print loop until offset > sram.Length do loop