org diretive: how to start program at pre determinated adr

General discussion on mikroC.
Post Reply
Author
Message
marcelo77
Posts: 21
Joined: 27 Nov 2008 18:28

org diretive: how to start program at pre determinated adr

#1 Post by marcelo77 » 28 Sep 2011 20:25

Friends, I need help:
I´m using a bootloader that is located in address 0x00 to 0xFFF so need to compile my programs to start in 0x1000, is this possible ?

I read the MikroC help, about diretive org, and it tell to specifie each function start address but, this is impractical.

Thanks and best regards,

Marcelo

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: org diretive: how to start program at pre determinated a

#2 Post by filip » 29 Sep 2011 08:27

Hi,

You can use something like this :

Code: Select all

void main() org 0x1000 {
....
}
Regards,
Filip.

marcelo77
Posts: 21
Joined: 27 Nov 2008 18:28

Re: org diretive: how to start program at pre determinated a

#3 Post by marcelo77 » 29 Sep 2011 11:54

filip wrote:Hi,

You can use something like this :

Code: Select all

void main() org 0x1000 {
....
}
Regards,
Filip.
Ok but this only defines the start address for function main, other functions the Mikroc put "below" this address overwriting my bootloader

thanks

Marcelo

sasa72
Posts: 89
Joined: 21 Apr 2011 05:21

Re: org diretive: how to start program at pre determinated a

#4 Post by sasa72 » 29 Sep 2011 15:05

Try following on top of your main file:

Code: Select all

#pragma orgall 0x1000

marcelo77
Posts: 21
Joined: 27 Nov 2008 18:28

Re: org diretive: how to start program at pre determinated a

#5 Post by marcelo77 » 29 Sep 2011 18:36

sasa72 wrote:Try following on top of your main file:

Code: Select all

#pragma orgall 0x1000
this don´t work on mikroc may be in mikroc pro but, i don´t have pro version, can you test it in mikroc pro ?

thank

sasa72
Posts: 89
Joined: 21 Apr 2011 05:21

Re: org diretive: how to start program at pre determinated a

#6 Post by sasa72 » 29 Sep 2011 19:12

It creates HEX file correctly - starting from 0x2000. Since Intel HEX file is a byte based, that is real position 0x1000 in MCU ROM (word based).

marcelo77
Posts: 21
Joined: 27 Nov 2008 18:28

Re: org diretive: how to start program at pre determinated a

#7 Post by marcelo77 » 29 Sep 2011 21:09

sasa72 wrote:It creates HEX file correctly - starting from 0x2000. Since Intel HEX file is a byte based, that is real position 0x1000 in MCU ROM (word based).
Ok, I´m using MPLab import->view program memory to certify the memory contents, which version did you use to do this: MikroC or MikroC PRO ?

thanks

Marcelo

sasa72
Posts: 89
Joined: 21 Apr 2011 05:21

Re: org diretive: how to start program at pre determinated a

#8 Post by sasa72 » 29 Sep 2011 21:34

HEX is created with latest mC PRO (5.01).

marcelo77
Posts: 21
Joined: 27 Nov 2008 18:28

Re: org diretive: how to start program at pre determinated a

#9 Post by marcelo77 » 29 Sep 2011 22:28

Ok, I tested in MIkroC PRO and works but I need to use MikroC "normal"

thanks

Marcelo

sasa72
Posts: 89
Joined: 21 Apr 2011 05:21

Re: org diretive: how to start program at pre determinated a

#10 Post by sasa72 » 29 Sep 2011 22:51

AFAIK, mikroC "normal" is an obsolete and abandoned product. If you have no specific reason to use it, it is highly recommended to switch to "PRO".

Another more complex solution may be to relocate your HEX file - disassemble and assemble with required ORG (with or without MPLAB).

Post Reply

Return to “mikroC General”