Part Number Hot Search : 
M37721 F9234 UPD75 000X1 13600 3KP13A SCBA05F VMTB60
Product Description
Full Text Search
 

To Download AN985 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  AN985/1098 1/7 application note executing code in st7 ram by 8-bit micro application team 1 introduction the purpose of this document is to give some guidelines about how to write and execute as- sembly code in ram with the st7 8-bit microcontroller. 2 st7 memory mapping the memory mapping in the st72251 is shown in the following figure. the st7 ram and rom locations are addressed and read in the same way. for the st7 core fetching and decoding instructions located either in ram or rom, take the same time, there is no limitation executing code in ram. but the difficulties come from the fact that the ram content is undetermined after power-up. so the ram locations have to be filled with the code after reset. there are two ways to do that: C the code is located in the st7 rom and is copied in ram after reset. 0000h ram rom (8k bytes) interrupt h/w registers 017fh 0080h short addressing ram (zero page) 16-bit addressing ram stack 64 bytes 007fh 0180h dfffh reserved (256 bytes) 0100h 0140h 017fh 0080h e000h ffdfh ffe0h ffffh 00ffh 013fh st72251 memory mapping & reset vectors 1
2/7 C the code is loaded in the ram through external communication. the application does not need special instructions to execute code in ram. but the manage- ment of the labels in ram has to be done carefully. the code has to follow the bytes directive if it is located in the short address ram named zero page (usually from 80h to ffh). all labels are treated into account as bytes. if the code is located in ram locations above the address 100h, it has to follow the words di- rective. 3 code copied from st7 rom to ram as described in the software example at the end of this document, we are using st7 directives which allow you to store, in a rom segment, the code to be used in ram. the directives used in our example are: segment byte at 100-13f 'ram1' segment byte at ef00-ffdf 'romtocop' segment 'ram1>romtocop' the code written in the romtocop segment is a copy of the ram1 segment. the volatile code is then stored in a non volatile location (the romtocop segment). so after each reset, the first instruction of the application must be translated from the romtocop segment to the ram1 segment. in the software example given in this application note, the two routines named addition and subtraction are located in the segment ram1>romtocop . after being copied in the ram1 segment the routines can be executed. 4 ram content filled through external communication the ram content is filled with the code to execute using an external communication from a device to the st7 through the st7 ios, sci, spi or i 2 c peripherals. when the transfer is com- pleted the code can be executed by loading the program counter with the first code address in ram. if the call instruction is used, the code located in ram must contain the ret instruction to be able to go back to the code located in rom.
3/7 5 flowchart the program given as example is structured as follows: reset mcu processes the call addition instruction jumping to ram1 segment to execute the addition routine. then goes back to the rom segment executing the ret instruction. rom segment code execution mcu processes the call subtraction instruction jumping to ram1 segment to execute the subtraction routine. then goes back to the rom segment executing the ret instruction. rom segment code execution copy the n code bytes of addition & subtraction routines from romtocop to ram1
4/7 6 software a software example is given below showing how to use code copied from st7 rom to ram. the assembly code given is for guidance only. the file cannot be used on its own. the com- plete software environment can be found on the web. st7/ ;************************************************************************ ; title: module1.asm ; author: ppg microcontroller applications team ; description: short demonstration program where code is executed ; in ram after being copied from rom to ram. ;************************************************************************ title "module1.asm" ; this title will appear on each ; page of the listing file motorola ; this directive forces the motorola ; format for the assembly (default) #include "st72251.inc" ; include st72251 registers and memory mapping file #include "constant.inc" ; include general constants file ;********************************************************** ; program code to copy in ram ;********************************************************** words ; define subsequent addresses as words ; meaning that all instructions are located ; in the address area above 0ffh in the st72251 ; memory mapping segment byte at 100-13f 'ram1' ; these lines define the segment to segment byte at ef00-ffdf 'romtocop' ; copy from romtocop to ram1 segment 'ram1>romtocop' ; the label values stored in the code located ; in the romtocop segment are defined ; to be executed from the ram1 segment .addition ; when the routine is called d2 is already in a add a,ramloc1 ; a = data2 + data1 ld x,a ; store (data1 + data2) in x register ret ; and return to main program in rom .subtraction ; when the routine is called d2 is already in a sub a,ramloc2 ; a= data1 - data2 ld x,a ; store (data1 - data2) in x register .end_ram ret ; and return to main program in rom
5/7 segment 'rom' ;***************************************************************** ; this instruction is one of the most important for the linker. ; it means that, until the next segment directive, ; all the code written below will be located in the rom part of the ; memory (start address e000h). ;***************************************************************** .main .difference equ {end_ram-addition} ; this label contains the number of bytes to ; copy in ram ld x,#difference.l ; load in x the number of bytes to copy cont ld a,(romtocop,x) ; indexed addressing mode ld (ram1,x),a ; x bytes from romtocop to ram1 dec x jrpl cont ; the content of the romtocop segment is ; copied to the ram1 location to be executed clr a ;its instruction's address is e000h. loop ld a,#data1 ; get data1 value ld ramloc1,a ; and put it in ram0 segment ld a,#data2 ; do it again for data2 ld ramloc2,a call addition ; call the other module routine stored in ram1 ; and execute it in this location ld ramloc3,x ; we stock the addition procedure's result ; in ram0 ld a,#data2 ; get data2 value ld ramloc2,a ; and put it in ram0 segment ld a,#data1 ; do it again for data1 ld ramloc1,a call subtraction ; call the other module routine stored in ram1 ; and execute it in this location ld ramloc3,x ; we stock the subtraction procedure's result ; in ram0 jp loop ; do the loop once again ; ******************************************** ; * * ; * interrupt sub-routines library section * ; * * ; ******************************************** dummy iret ; empty subroutine. go back to main (iret instruction) segment 'vectit' ; *******************************************************************
6/7 ; this last segment should always be present in your own programs. ; it defines the interrupt vector addresses and the interrupt routines' labels ; depending on the microcontroller you are using. ; refer to the mcu's datasheet to see the number of interrupt vectors ; used and their addresses. ; remember that this example is for a st72251 based application. ; ******************************************************************* dc.w dummy ;ffe0-ffe1h location dc.w dummy ;ffe2-ffe3h location .i2c_it dc.w dummy ;ffe4-ffe5h location dc.w dummy ;ffe6-ffe7h location dc.w dummy ;ffe8-ffe9h location dc.w dummy ;ffea-ffebh location dc.w dummy ;ffec-ffedh location .timb_it dc.w dummy ;ffee-ffefh location dc.w dummy ;fff0-fff1h location .tima_it dc.w dummy ;fff2-fff3h location .spi_it dc.w dummy ;fff4-fff5h location dc.w dummy ;fff6-fff7h location .ext1_it dc.w dummy ;fff8-fff9h location .ext0_it dc.w dummy ;fffa-fffbh location .softit dc.w dummy ;fffc-fffdh location .reset dc.w main ;fffe-ffffh location end
7/7 the present note which is for guidance only aims at providing customers with information regarding their products in order for them to save time. as a result, stmicroelectronics shall not be held liable for any direct, indirect or consequential damages with respect to any claims arising from the content of such a note and/or the use made by customers of the information contained herein in connexion with their products. information furnished is believed to be accurate and reliable. however, stmicroelectronics assumes no responsibility for the co nsequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of stmicroelectronics. specifications mentioned in this publicati on are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics prod ucts are not authorized for use as critical components in life support devices or systems without the express written approval of stmicroele ctronics. the st logo is a registered trademark of stmicroelectronics ? 1998 stmicroelectronics - all rights reserved. purchase of i 2 c components by stmicroelectronics conveys a license under the philips i 2 c patent. rights to use these components in an i 2 c system is granted provided that the system conforms to the i 2 c standard specification as defined by philips. stmicroelectronics group of companies australia - brazil - canada - china - france - germany - italy - japan - korea - malaysia - malta - mexico - morocco - the neth erlands - singapore - spain - sweden - switzerland - taiwan - thailand - united kingdom - u.s.a. http://www.st.com


▲Up To Search▲   

 
Price & Availability of AN985

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X