Sonsivri

Electronics => Pic C Languages => Topic started by: Elysion on March 08, 2015, 03:40:38 15:40



Title: XC8 - MikroC / pragma udata
Post by: Elysion on March 08, 2015, 03:40:38 15:40
Hi,

Is there any similar functionality like #pragma udata - (XC8) in mikroC? I don't want to address every register with absolute addressing.

Thanks,
Oguz


Title: Re: XC8 - MikroC / pragma udata
Post by: flo0319 on March 08, 2015, 04:18:32 16:18
Hi,
I am not sure if I understood what you really want; in mikroC if you want to set an absolute address for a variable you need to use absolute directive :
Code:
short x absolute 0x22;
// Variable x will occupy 1 byte at address 0x22
int y absolute 0x23;
// Variable y will occupy 2 bytes at addresses 0x23 and 0x24

Usually you will let linker to assign addresses and align variables from optimization reasons, even more in a PIC controller where the RAM is split in banks


Title: Re: XC8 - MikroC / pragma udata
Post by: Elysion on March 26, 2015, 03:25:28 15:25
Hi,

I have a lot of inline assembly in my code due to time critical issues and I don't want to change banks forward/backward due to variable locations.
So I have 40+ variables needed to be in one bank. There are structures, custom types for these variables. Calculating size/address for each to write to each absolute parameter  is very time consuming. "pragma udata" type directive is the exact needed one.

Thanks,
Oguz


Title: Re: XC8 - MikroC / pragma udata
Post by: h0nk on March 26, 2015, 05:36:14 17:36
Hello Elysion,

i am running V1.31 of XC8.
But using:

#pragma udata blub

gives:
unknown pragma "udata"

Absolute addressing in XC8 is done with "@", as in:
char c @ 0x34;
In XC8 You should also be able to put Your common variables in a psect which You can define.

I do not use MicroC anymore, so i am sorry not able to help You with Your question.
But MicroC is missing a dedicated linker, so i am afraid there are no precautions to put variables together.

But: What should this pragma doing?


Best Regards