assembly avr tiny and 'ld'

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello, I am using a ATtiny12 which has no
RAM. I am not having any difficulties except in
experimenting with the indirect 'LD' instruction.
The tiny12 manual list the LD as a supported instruction as

Quote:
LD Rd,Z (per the manual)
as shown in the instruction list summary.
Example used:(using the simulator version 2)

.cseg
.org 0x00
main:
	ldi		ZH,0x01
	ldi		ZL, 0x00
	ld		r20,Z ;R0 doesn't work either
	inc		ZL
	ld		r21,Z
.cseg
.org 0x100
Myflash:
	.db 0xee
.....

Trying to use R0 instead of R20 as in the code shown, I still get nothing or 00.
Using the simulator , the setting of the ZH/ZL seems ok. But attempting to use LD or LDI does not get the expected value.

And, yes I know the Tiny12 is a older device, but I did not understand this part of using the no ram chip.

Can anyone explain or offer a small snippet such
as entered above.
Thanks for any clarification.

I'll believe corporations
are people when Texas executes one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

From the instruction set manual:

Quote:
For parts without SRAM, the data space consists of the Register File only.
That is to say, the registers are mapped to SRAM addresses. For the code snippet above, the address is set to 0x100 which is above any of the registers. The address must be no greater than 0x1F. An address of 0x08 would access R8.

As far as LDI is concerned, there should be no problem as it has nothing to do with SRAM.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, I just read that in the manual.
So, I changed the pointer (Z) to point to the
address of a register and it worked.

What if one wants to load (LD) a value from
program memory (flash).
It seems that LPM is not supported by such an 'old' device.
Oh well, found about 3 of them and decided to use them for something.
No wonder it is no longer an active device.....

I'll believe corporations
are people when Texas executes one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Oh well, found about 3 of them and decided to use them for something.

With Tiny13 and Tiny25 so reasonably priced nowadays, consider the payback on your time to struggle with the Tiny12.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch :

Quote:
With Tiny13 and Tiny25 so reasonably priced nowadays, consider the payback on your time to struggle with the Tiny12.

Yes,I agree , quite a struggle to use such a limited chip.

I have a prototype PCBA that I was using for the
Tiny85 and after finding the T12 stored away I just wanted to see if I could bring them back to life.
That also required using assembly programming which I like to do every now and then,
just for the challenge, So,after doing a little experimenting, I can see
results can be a challenge.

The sad part is, I see no way to use a constant
stored in flash/program memory. I guess EEPROM
is the only way to do that.

Moot point, as I don't intend to use the chips for anything other than 'checking' them out.
:lol:

I'll believe corporations
are people when Texas executes one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
It seems that LPM is not supported by such an 'old' device.
Why would you say that? It is in the datasheet in the instruction set summary.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Why would you say that? It is in the datasheet in the instruction set summary.

My eyes :oops:

I will give that one a shot!
Thanks

I'll believe corporations
are people when Texas executes one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One more question regarding the LPM, I see it works, but can't seem to get the right
syntax to do an auto increment/decrement in
using the lpm. :oops:

Well, time to call it night ......

I'll believe corporations
are people when Texas executes one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
but can't seem to get the right syntax to do an auto increment/decrement in
using the lpm.
You can't get it because the tiny12 doesn't have it. All it can do is load what Z is pointing to into R0.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
You can't get it because the tiny12 doesn't have it.

Well, I just incremented the ZL register and then executed a LPM, works ok that way. :D

I'll believe corporations
are people when Texas executes one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Well, I just incremented the ZL register and then executed a LPM, works ok that way.

...as long as ZL is low when you start. What if your data is at 0x2FF?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
What if your data is at 0x2FF?

It is obvious to me the the wrap around
of the address range, going from $02ff to
$0300 and what that means.
I was only interested in the fact that the Tiny12 can not support auto increment/decrement as in other more capable
devices.

And, I think this is the end of this thread
as far as I am concerned, I am back up to
speed on these RAMless devices and they do have their limitations.
Now, I will just remove the Tiny12 from the prototype PCBA and move to the next endeavor.

Thanks for all of the input(s) from everyone. BTW, the ATtiny12 manual from the Atmel web site is a dumbed down version but I was able to get the 'full' version from technical support, thanks Atmel

I'll believe corporations
are people when Texas executes one.