CPEEK/de

From MCS Wiki AVR
< CPEEK
Revision as of 21:13, 15 February 2013 by Admin (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

= (**COPIED FROM ENGLISH PAGE**) === Action

Returns a byte stored in code memory.

 

 

Syntax

var = CPEEK( address )

 

 

Remarks

Var

Numeric variable that is assigned with the content of the program memory at

address

Address

Numeric variable or constant with the address location

 

There is no CPOKE statement because you can not write into program memory.

Cpeek(0) will return the first byte of the file. Cpeek(1) will return the second byte of the binary file.

 

 

See also

PEEK , POKE , INP , OUTSETREGGETREG

 

 

Example


'-----------------------------------------------------------------------------------------
'name : peek.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demonstrates PEEk, POKE, CPEEK, INP and OUT
'micro : Mega48
'suited for demo : yes
'commercial addon needed : no
'-----------------------------------------------------------------------------------------
 
$regfile = "m48def.dat" ' specify the used micro
$crystal = 4000000 ' used crystal frequency
$baud = 19200 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
 
Dim I As Integer , B1 As Byte
'dump internal memory
For I = 0 To 31 'only 32 registers in AVR
B1 = Peek(i) 'get byte from internal memory
Print Hex(b1) ; " ";
'Poke I , 1 'write a value into memory
Next
Print 'new line
'be careful when writing into internal memory !!
 
'now dump a part ofthe code-memory(program)
For I = 0 To 255
B1 = Cpeek(i) 'get byte from internal memory
Print Hex(b1) ; " ";
Next
'note that you can not write into codememory!!
 
Out &H8000 , 1 'write 1 into XRAM at address 8000
B1 = Inp(&H8000) 'return value from XRAM
Print B1
End

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language