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.

Data memory is a problem

Status
Not open for further replies.

Peet19

Member
Hi everyone!
When I allocate registers from memory, the data memory amount indicator does not change.
Why is this? What could be the problem?
I use MPLAB 8.92.
For example, I reserved 100 Bytes, but the display didn't even move. I don't understand what could be wrong. Does anyone have any ideas?

CBLOCK 0x0
CNT1 : 100
CNT2
ENDC

1672757486031.png


Thank you in advance for your help!
 
I do not understand what you mean. in Assembly
(CBLOCK) with
I reserved 100 registers from the memory for the sake of the example.
Everything is fine with this, because I can see in the file registers window that it is indeed reserved and can be used, but I don't get feedback about the data memory usage. Why is this?
I cannot use UDAT_ACS because I use an 18F24K22 microcontroller. As far as I know, UDATA_ACS can only be used with PIC18Cxxx controllers.
 
Last edited:
Look. I reserve 2 registers named CNT1 and CNT2 at addresses 0x008 and 0x009 using CBLOCK. So two 8-bit registers are reserved, i.e. 2 bytes of reserved data memory. But there is no feedback about data memory usage. I do not understand this.

1672825263323.png
 
Just run up an old program, pic18F45K22 in mplab8.92 and that does use the registers specified and also get nothing showing in the Gauge.
Looking on the web, seems its a common problem but not seen any actual answer ?

001660.jpg
 
In the present version of MPLab X, memory use is only shown after compiling the program.

Also, if the program is not being built in "debug" mode, it relies on the option

"Load symbols when programming or building for production"

being ticked in the project properties -> Loading section.
(I don't know if anything of that applies to MPLab 8, I've not used that in many years)
 
CBLOCK does not allocate ram... what CBLOCK does is assign constant values to the symbols declared inside it. It's basically the same as a sequence of EQUs.

The way to actually allocate ram is to use RES, and that's only available in relocatable mode.
I think you'll only see the 'Data Memory' in the usage gauge is if you use one of the UDATA directives and RES
 
You are right, thank you. I just don't understand why it doesn't allow addresses below 0x060 to be reserved. Maybe that's why ACCESS RAM uses it?

DA1: UDATA 0x060
DAT1 RES 1
DAT2 RES 1
DAT3 RES 2
DAT4 RES 1

that's how it worked :)
 
for PIC18 devices locations in the access ram are declared using UDATA_ACS.

I just double-checked, and what I said before about RES isn't correct... according to the mpasm users guide you can use RES with both absolute and relocatable code.
 
I did it, thanks.
So which one should I use now? CBLOCK or UDATA_ACS?
I don't understand the difference. Can you help me?

DATAS: UDATA_ACS 0x010
DAT1 RES 1
DAT2 RES 1
DAT3 RES 1
DAT4 RES 1
 
In general terms:
Absolute means data memory and program addresses are given explicitly in the program.

Relocatable means addresses are given as relative offsets to the program counter or another register, so the program does not need to be loaded to any specific address in the CPU memory space, it can run equally well at any location.

There are variations & different IDEs or compilers may use different terminology; ie. if you are building a program that uses multiple separate source files, they may all apparently use the same addressing, but the compiler "loader" program patches all the additional file addresses as it builds the complete machine code program & sequences them after the main module, to give each part a different address range.

Plus things such as Windows .exe files, which are absolute but include a patch table the operating system uses to adjust all the values in absolute address instructions, so the program can run from any location once the OS has finished patching it.
 
I understand, thank you. If I understand correctly, the relocatable is a better solution?
Why don't my own registers appear in relocatable mode in the Watch window?
 
In relocatable mode you have to use the linker (MPLINK) to generate a .cof file with symbolic info.
There should be a copy of the "MPASM_MPLINK_User_Guide.pdf" in your mpasm install folder.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top