all i wanna do is peek(x) with an atmega2560. but it seems that peek just doesn't work. so is there any way to just read memory location x?
is it possible to do this:
LDI 0x1E, 0x00
LDI 0x1F, 0x22 ' 0x22, address to peek from -> register Z
LD 0x1D, Z ' load from 0x22 -> 0x1D
STS 0x105 0x1D ' store 0x1D -> portJ
and then do
localvar = PORTJ
this is what i'm trying to do but it won't work:
dim addresses(3)
addresses = 34, 37, 40 ' ports a b and c
dim pins(3)
mask = 0b01101001
for xx = 1 to 3
inbyte = peek(addresses(xx))
pins(xx) = inbyte & mask
next
Last edit: louie 2018-05-02
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't have a 2560 but a uno 328p has ports mapped to sram.
portb is 0x03 (0x23) pins address, 0x04(0x24) direction, 0x05(0x25) data.
so poking these should change portb.
If that is what your trying to do ..why not just use basic commands not peek and poke?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This turns bit 0 to 5, portb on and off,square wave on scope. Why not all bits?
So poke works. Note the port address is the second value from last post.
poke (0x24,255)
do
poke (0x25,255)
wait 20 ms
poke (0x25,0)
wait 20 ms
loop
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hey Stan this is a sorta repeat of my other question which you answered for me yesterday that i posted before i saw your answer.
it goes back to this rooutine:
dim addresses(3)
addresses = 34, 37, 40 ' ports a b and c
dim pins(3)
mask = 0b01101001
for xx = 1 to 3
inbyte = peek(addresses(xx))
pins(xx) = inbyte & mask
next
and it never worked. i connected a ground wire to one of the pins of port c, but it always came back with portc = 255. so what to do? peek is the only way i know to reference a register numerically, but afterward i thought of using assembly code.
then i saw your answer:
dim result(24) as byte
for count=1 to 24
pbit=fnlsl(1,count%8)
if count/8=0 then result(count)=porta and pbit
if count/8=1 then result(count)=portb and pbit
if count/8=2 then result(count)=portc and pbit
next count
and it's the best solution i have. thanx :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
First, if a port is output and high..don't ground it. If it was connected to a led to ground you'd use a resistor in series to lower the current to say 30 ma.
I'll try your code on a uno later.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
all i wanna do is peek(x) with an atmega2560. but it seems that peek just doesn't work. so is there any way to just read memory location x?
is it possible to do this:
LDI 0x1E, 0x00
LDI 0x1F, 0x22 ' 0x22, address to peek from -> register Z
LD 0x1D, Z ' load from 0x22 -> 0x1D
STS 0x105 0x1D ' store 0x1D -> portJ
and then do
localvar = PORTJ
this is what i'm trying to do but it won't work:
Last edit: louie 2018-05-02
Peek and poke does work in gcb.
I looked at 2560 sram map. I don't understand mapping registers or reserved and fast code in sram.
I don't have a 2560 but a uno 328p has ports mapped to sram.
portb is 0x03 (0x23) pins address, 0x04(0x24) direction, 0x05(0x25) data.
so poking these should change portb.
If that is what your trying to do ..why not just use basic commands not peek and poke?
This turns bit 0 to 5, portb on and off,square wave on scope. Why not all bits?
So poke works. Note the port address is the second value from last post.
Peek and poke do work with io regs it seems.
I edited this from being an error report..my error :(
Last edit: stan cartwright 2018-05-02
hey Stan this is a sorta repeat of my other question which you answered for me yesterday that i posted before i saw your answer.
it goes back to this rooutine:
and it never worked. i connected a ground wire to one of the pins of port c, but it always came back with portc = 255. so what to do? peek is the only way i know to reference a register numerically, but afterward i thought of using assembly code.
then i saw your answer:
and it's the best solution i have. thanx :-)
First, if a port is output and high..don't ground it. If it was connected to a led to ground you'd use a resistor in series to lower the current to say 30 ma.
I'll try your code on a uno later.
no it's input and high and yeah i'd like to see how that works