Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How is memory managed with micro controllers using assembly?

Status
Not open for further replies.

theKbStockpiler

Newbie level 3
Joined
Jun 25, 2010
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Upstate NY
Activity points
1,310
I can't find any info on this. Let's say I have a PIC configured as a data logger. How do I allocate and keep track of the addresses I am using? Do I start with the first address and use a register and use an expression to add to the current address for the next data to consume? Do I implement a manual type of file system?

Thanks for looking at this thread!
 

Re: How is memory managed with micro controllers using assem

Hi,

If you are storing data as in a logger then I would assume you will want to store the data in the chips on board EEPROM or an external EEPROM chip if you want something larger.

The easiest way to address the EEPROM or large areas of RAM is by means of the FSRs - File Select Registers - see the Memory section of the datasheet for the chip you are using...?
As usual the Microchip manual is so clear and easy to follow for the beginner, so here is a simple 18F example.

Code:
 		  clrf	FSR1H			; FSR routine to clear ram banks 0 -4 only
		   clrf	FSR1L	      ; here the address loaded / cleared to 0x0000	
clrram	clrf	POSTINC1		; clear location and inc
  	    movlw	0x05			; now in bank5 ?
 		  subwf	FSR1H,W
 		  bnz	  clrram	    ; carry on clearing if not at bank5
 
Re: How is memory managed with micro controllers using assem

Thanks for the reply! :D
If I have your attention I was wondering how people "think" when they are implementing MCU memory chores. I have studied the basics of micro controllers but nothing in-depth for a couple of years. Right now I'm trying to get the memory concepts squared away before I delve back into a whole tutorial on PICs.Do I have to keep the last address that I wrote data to in a register and then use an expression to increment it for my next address to send data to? Do I have to manually keep track of the address space that I have used? Is it advisable to concoct a Table for the memory chip? Like the" File Allocation Table" ( FAT) Is it customary or to put raw data in a memory address? Is there some term I could search for that is the proper topic that this stuff falls under?


Thank You for looking at this thread!
 

Re: How is memory managed with micro controllers using assem

Hi,

Well can see where you are coming from with your questions and there are several ways to answer your points - however that could lead to a long discussion.

As to a tutorial on Memory usage, the Microchip site has masses of info on it, however finding it is like a treasure hunt, only today a friend mailed me some Microchip Video tutorials for Mplab Simulator he had easily found on a non microchip site !


Think again a simple example will speak volumes, though here I am refering to the pic18F chips whos memory is organised so much better than the more popularly covered 16F chips.

Again look at a datasheet, say the pic18F4520 or the 16F628 and locate the DATA Memory Map.
This shows how it is divided in to two distinct areas, the SYSTEM registers and the USER Registers and the locations /addresses the occupy.

On the 4520 you would first indicate what Label / Names you want to assign to your User registers

cblock 0x00 ; start user ram at location h 0x00
counter1 ; label counter1 is assigned to memory location 0x00
counter2 ; to 0x01 etc etc
counter3
temp1
temp2
temp3

endc ; end of data

In your main program code you then simply refer to that ram location by the Label and the system takes care of everything for you.

Movlw 0x45
movwf counter1 ; load data 0x45 into counter 1

incf counter1

decf counter1


When you need to address large arrays of data then the use of labels become impractical so you can then use the FSR as mentioned before to read and write to the locations you specify.

There are loads of assembler tutorials around, have a look at some and use one that seems good to you - using MPLAB and its Simulator you can follow each instruction step by step and see how the system is dealing with the data.

Have a look at
ttp://www.youtube.com/watch?v=pnkUOL0mmyA&feature=related
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top