how to initial stack on ATTiny 26?

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

I quess with tiny26 this doesn't work...

From Academy, written by Eivind:

ldi	TEMP,low(RAMEND)	; Set stackptr to ram end
out	SPL,TEMP
ldi	TEMP, high(RAMEND)
out	SPH, TEMP

This is from ATTiny26 datasheet:

Below is a code from tn26def.inc:

; ***** DATA MEMORY DECLARATIONS *****************************************
.equ	FLASHEND	= 0x03ff	; Note: Word address
.equ	IOEND	= 0x003f
.equ	SRAM_START	= 0x0060
.equ	SRAM_SIZE	= 128
.equ	RAMEND	= 0x00df
.equ	XRAMEND	= 0x0000
.equ	E2END	= 0x007f
.equ	EEPROMEND	= 0x007f
.equ	EEADRBITS	= 7
#pragma AVRPART MEMORY PROG_FLASH 2048
#pragma AVRPART MEMORY EEPROM 128
#pragma AVRPART MEMORY INT_SRAM SIZE 128
#pragma AVRPART MEMORY INT_SRAM START_ADDR 0x60

...should I do something like:

;**** INIT STACKPOINTER *************
ldi temp, 0x0061
out sp, temp

Without the codes above AVR Studio gives me everykind of warnings, like stack overflow etc. etc. I'm still uncertain is the right address 0x0061?

I am asking this because I have a flashing led on board and sometimes it woun't flash?

Regards
heguli

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

RAMEND is where the stack must begin.

RESET:	ldi	temp, RAMEND
	out	SP, temp

RES

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

Thanks RES,
...one problem solved.

Regards
heguli

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

Quote:
RAMEND is where the stack must begin.

RAMEND is where the stack usually begins. There is no reason why it has to begin there. RAMEND is, however, the highest address that the stack can begin at simply because there is no ram after RAMEND.

Regards,
Steve A.

The Board helps those that help themselves.

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

Thanks Steve to point that out. So any RAM area will do except the lowest value 0x0060.
Looks like my real problem lies somewhere else... Thanks again guys!

Regards
heguli

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

If it's a short program, post the code and we can see what you're trying to do.

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

@dksmall:
I already solve the problem...
https://www.avrfreaks.net/index.p...
...but thanks anyway man. I was lucky this time :D

Regards
heguli