Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Viewing amount of memory used

Status
Not open for further replies.

gregmcc

Member
I've been busy writing a clock and LCD program in asm for the 16F628 and after some kind I worked out it kept crashing due to its size.

I loaded the program up in a simulator and the LCD displays what its supposed to. If however I make the program too big it keeps crashing.

From the datasheet the program memory is 2K. I think I might have exceeded that but I don't know where to check? In MPLAB there's a memory usage guide, but program and data memory display 0.
 
gregmcc said:
In MPLAB there's a memory usage guide, but program and data memory display 0.
You have to 'import' the hex file (File->Import...). Then it'll show the memory usage.

Or open the .LST file.
 
Last edited:
Aghh thanks eng1. As easy as that :) It doesn't work if you don't import the hex file.

That leads onto my second problem :( The amount of program memory showing is 340 out of 2048. I thought it was a memory problem but it doesnt look like it.

I've now taken Nigel's LCD tutorial and simulated the problem. I've put in a bunch of NOP's in the code and it falls over on the simulator. If its not memory related, what's causing it?

I've attached the asm file. If someone could please have a look and tell me if it memory related or something more sinister.
 

Attachments

  • lcd.asm
    5.5 KB · Views: 159
gregmcc said:
I've attached the asm file. If someone could please have a look and tell me if it memory related or something more sinister.
I doubt that it can be related to the memory space available (there's plenty of free memory). Try moving the tables right next to Stop: goto Stop and see if that helps :)



EDITED: typos corrected.
 
Last edited:
Holy smokes - it now works!!

Now I'm confused - what difference does the table location make? Its all part of the same program memory isn't it?
 
In MPLAB you can also use View->Program Memory. This is very crucial when dealing with tables. You can easily see when a table crosses a 256 byte boundary as an address rolls over from XFF to (X+1)FF.

Wait until you come against the 2046 byte program boundary in larger sized word chips. God bless Microchip. :)
 
A little bit of code I picked up somewhere:

Code:
Table1: 
        ADDWF   PCL, f   ;jump forward by value of W 
        retlw   'A' 
        retlw   'B' 
        retlw   'C' 
        retlw   'D' 
        retlw   'E' 
        retlw   'F'  ;end of table 
 IF HIGH($)!=HIGH(Table1) 
 ERROR "End of table is not in same page as start of table" 
 ENDIF
It will give an error at compile time if Table1 crosses a page boundary.
 
That is a good one kchriste.

I wonder if that idea couldn't be expanded upon to conditionally assemble the extra instructions for "256 byte boundary tolerant" code only when it's actually needed?

Mike
 
Mike said:
That is a good one kchriste.

I wonder if that idea couldn't be expanded upon to conditionally assemble the extra instructions for "256 byte boundary tolerant" code only when it's actually needed?

Mike

No it can't. I tried writing such a macro and due to forward references the compiler throws a wobbly. First pass the assembler doesn't know the end address of the table and so can't calculate the offset needed. Second pass it inserts the required space and all labels after that are now a different value. I also tried to write a conditional far call macro and that suffered the same problem.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top