Discussion in "8051 Discussion Forum" started by    kikoues    Sep 19, 2010.
Sun Sep 19 2010, 01:48 PM
#1
As i have run out of registers, i am using memory locations to store the values of some variables. i am using the memory bank 30 to 7h. my code simulates as expected however it does not run correctly on the micrcontroller. i am reading a data from a peripheral. i probed with oscilloscope its signal at my micrcontroller port, it is as expected in my program. however my output is badly synchronised and does not work as expected although it simulatedsfine. any tips please because i am not able to fix it. i have found the following , which may be the cause of my problems although i don't understand what the author means by system stack
General Purpose RAM: 30h to 7Fh
These 80 bytes of Internal RAM memory are available for general-purpose data
storage. Access to this area of memory is fast compared to access to the main memory
and special instructions with single byte operands are used. However, these 80 bytes
are used by the system stack and in practice little space is left for general storage. The
general purpose RAM can be accessed using direct or indirect addressing modes.
Examples of direct addressing:


cheers
Sun Sep 19 2010, 06:24 PM
#2
hi kikoues
it is better u upload ur program which u made then anyone can help u better

stack is the temporary memory by default it is bank1
when we call a function then its present address is push to stack the control goes to function after executing the function it pop the address and goes there from where it comes
Mon Sep 20 2010, 03:17 PM
#3
thanks majoka, i fixed the problem by avoiding this bank although i still don't understand what the author means by SYSTEM STACK
Mon Sep 20 2010, 06:49 PM
#4
Stack is part of ram memory used for temporary storage data when controller makes a context switch during call to a subroutine or an interrupt routine. Data is stored on stack by pushing important working registers and poping them back.

Register Banks are part of RAM memory from 00H to 1FH. In 8051 the stack pointer is loaded at 7H on power up. so incase you are going to use memory banks in your code you have to setup stack pointer to a safe location that is not used by your program.

Lets say you are not using area above 50H in your RAM memory. so setup SP to 50H e.g.
mov SP, #50H ;load stack pointer at 50H


So you will now have the area from 20H to 50H free to use for your general purpose ram, and 0H to 1FH for memory banks and 51H to 7FH for stack. simple isnt it?

Incase you are using an 8052 based controller which has 256 bytes of ram so stack pointer can be initialized to 80H instead. which means you have 20H to 7FH available for general purpose use and 80H to FFH for stack.

Hope you get the point now

[edit: changed the wrong reference]


[ Edited Tue Sep 21 2010, 08:18 PM ]
Tags 8051 stack setupstack initialization 80518051 stack pointer initialization
Mon Sep 20 2010, 06:53 PM
#5
SYSTEM STACK is a stack as i mention above that is by default bank 1
Tue Sep 21 2010, 04:52 PM
#6
Many thanks Ajay and Majoka for your replies. I am coding in assembly, so why are you are making ref. to compiler? also in my programs, i am using R0-R7 registers + memory locations to access and store data. my code operates correctly when i define the memory locations in the 08-E range while initialising SP @ 0fH as you showed in your code.
I am using subroutineS but without PUSH and POP. yet my code does not work when i define the memory location iin the bank 30-7f. any explanation?

also i have read in the ref that the band 20-2f is bit addressable. so how can the assembler find out if
clr 20 is setting the bit 20 to zero or instead setting the byte 20 to zero
...sorry but i am confused...
Tue Sep 21 2010, 05:24 PM
#7
ok dear kikoues
it is better u post ur code here so we help u better
ok u confused in compiler term u r doing coding in assembly so assembler is used in assembly. in assembly coding u hav to do check and balance of every thing by urself even memory banks , stack etc
30 to 7f memory is a scrath pad mean general purpose ram may be u defining it in wrong way when u use this memory then mov sp,#07
but it is better u post ur code for this question
20 to 2f is bit addressable memory
clr 20 means move zero to 20 location of bit addressable memory mean clearing a bit not a byte
if u want to move zero to a 20 location byte then syntax is
mov 20h,#00h
hop so nw ur cleared
Tue Sep 21 2010, 08:13 PM
#8
and my mistake i should have said controller instead of compiler or assembler as controller is the one doing a context switch. during a context switch push pop is done by controller automatically you have no control over it.

an example, when you make acall to a subroutine, and at end of subroutine you execute ret statement. to make ret run correctly controller should know where to return, so this return addressed is pushed to stack when a call is made and poped from stack when returning from subroutine.

second example, you have written a routine where you're using registers r0 to r7 suddenly an interrupt comes so controller will push the return address to stack. now in ISR you are again going to use r0 and r1 so your application must push those working register to stack before using them in ISR while coming back from ISR you pop those two registers and return back where you've left. thats how stack is used.

Get Social

Information

Powered by e107 Forum System

Conversation

ExperimenterUK
Sat Oct 12 2019, 10:23 PM
Log in.. then post your code in the 8051 forum
Sat Oct 12 2019, 10:18 AM
Bhadra Sajikumar
i am doing a countdown timer with 8051 for my project, unfortunately our professor had to take a leave of absence before he could teach us most of it.. can someone explain the .asm code of it for me?
Mon Sep 23 2019, 07:37 AM
Nathaniel
I am doing a project for my schools wireless security system with cameras,sensors and spot lights using 8051 micro controller, could you help me out with the design and its source code.
Wed Sep 18 2019, 08:48 PM
Caryn Kover
Thank you for your time,
ExperimenterUK
Mon Aug 05 2019, 07:09 PM
@Ismail ..post in forum, give details
Mon Aug 05 2019, 04:33 PM
Ismail balghmi
Hello. Please I won't download
ExperimenterUK
Wed Jul 24 2019, 12:47 AM
@BUSTER123 Please post in the forum
Tue Jul 23 2019, 06:13 PM
BUSTER123
hello! newbie here. i am kind of a guy who hates using ready - made existing libraries, so this helped a lot as i was trying to control and write to a character lcd display. however, i can't figure out how to set the cursor position. for example, i want to set it to the 5th column in the first row, so position 5. so according to the table, i am sending 10000101 on the 8 data lines of the lcd (register select pulled low). the cursor does not move there however. and i cant move the cursor left or right too. is it something wrong that i am doing? thank you.
ExperimenterUK
Thu Jul 11 2019, 07:55 PM
@ramos https://www.theengineeringprojects.com/2017/09/l298-motor-driver-library-proteus.html
ExperimenterUK
Thu Jul 11 2019, 07:44 PM
@praveen123. Can you give a link to the project ?

Downloads

Comments

Casmir
Wed Nov 13 2019, 06:25 AM
DeepakBGattani
Mon Nov 11 2019, 01:31 PM
Jeanbusatta
Sun Nov 10 2019, 04:42 AM
mdayaz
Sat Nov 09 2019, 03:41 PM
baoyen123
Fri Nov 08 2019, 10:06 AM
xiwang
Fri Nov 08 2019, 07:28 AM
ilylily07
Tue Oct 15 2019, 04:32 PM
hientran123
Tue Oct 15 2019, 02:27 AM

Online

Guests: 39, Members: 1 ...
ilylily07 viewing chatbox_menu.php

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38103
Newest member: Casmir
Forum Activity
Jeanbusatta Avatar
Posted By Jeanbusatta
Sun Nov 10 2019, 04:43 AM
ty, really needed it
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Oct 22 2019, 05:18 AM
wimac Avatar
Posted By wimac
Mon Oct 21 2019, 09:18 AM
I’ve been following this thread and looking at the...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sun Oct 20 2019, 03:09 PM
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sun Oct 20 2019, 03:02 PM
sir, when i on display ,sometime 3rd display is no...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sun Oct 20 2019, 02:53 PM
sir, when i on display ,sometime 3rd display is no...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Oct 20 2019, 12:21 AM
Your code seems okay on my simulationTry my code o...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sat Oct 19 2019, 07:13 PM
please find video attachment. 3rd & 4th displa...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sat Oct 19 2019, 07:05 PM
sir, 3rd and 4th dot matrix display flickering, ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Oct 18 2019, 09:18 PM
Hopefully you understand some of the program.Which...