Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Newbie: Need to set initial stack pointer at a specific addr

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
Zvoc47

Bascom Member



Joined: 02 Apr 2015
Posts: 21

PostPosted: Fri Apr 03, 2015 11:33 pm    Post subject: Newbie: Need to set initial stack pointer at a specific addr Reply with quote

Hello, I just bought BASCOM-AVR so I can program ATXMEGA128A1.
I've read about the hardware stack, software stack and the frame.
What bothers me is how do I set that the CPU stack pointer isn't at 0x3FFF which is the end of SRAM, but 0x2FFF.
I don't want to do this manually like writing to the CPU SPL and SPH because I think that will overflow the software stack.
The reason why I'm putting the stack pointer at 0x2FFF is because there will be a user program that my debugging program will load with stack pointer at 0x3FFF and it will be context switching like a little OS.

(BASCOM-AVR version : 2.0.7.8 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6198
Location: Holland

blank.gif
PostPosted: Sat Apr 04, 2015 7:45 am    Post subject: Reply with quote

the hardware stack pointer is always set to the last sram address.
you could change the RAMEND value in the dat file. that is the most simple solution.

_________________
Mark
Back to top
View user's profile Visit poster's website
Zvoc47

Bascom Member



Joined: 02 Apr 2015
Posts: 21

PostPosted: Sun Apr 05, 2015 12:07 am    Post subject: Reply with quote

Thank you! RAMEND is exactly what I wanted Smile But can I set the start position of compilation for example if I want to compile at 0x8000?
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6198
Location: Holland

blank.gif
PostPosted: Mon Apr 06, 2015 9:15 pm    Post subject: Reply with quote

you mean you want the code to start at &H8000 ? you could use $loader. that is used for boot loaders.
_________________
Mark
Back to top
View user's profile Visit poster's website
Zvoc47

Bascom Member



Joined: 02 Apr 2015
Posts: 21

PostPosted: Tue Apr 07, 2015 9:23 am    Post subject: Reply with quote

My program flash start: 0x000000
My program stack start: 0x2FFF (I don't want to set this in the DEF file because I'll get the out of bounds error for accessing above this)

User's program flash start: 0x008000
User's program stack start: 0x3FFF

My program uses RTC for context switching between these two programs.
I succeeded by using SPH=$2F.
However, I cannot read the stack pointer. Whenever I try to read and print, I get zeros.
Reading the stack pointer will be important so that the user can use the "cpu" command to print out all the registers to USART which are put into my array by context switching.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum