ROM memory full?

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
zinckingeye
Posts: 1
Joined: 26 Dec 2010 23:23

ROM memory full?

#1 Post by zinckingeye » 26 Dec 2010 23:27

why my compiler say that the 'There is not enough ROM' even they only reach 3k ROM in PIC16f877a?

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: ROM memory full?

#2 Post by tihomir.losic » 27 Dec 2010 13:26

Hello,

The problem here is that the size one of your functions is too big that it cannot be successfully fitted into a single page of PIC16F877A.
The page limit is 2K and your function alone was 1859 addresses long. Because it calls other procedures on other pages, PCLATH has to be set in order for it to access
the page with the destination called procedure. Because linker doesn't know how everything will turn out to be at the end,
the pessimistic approach is implemented so that before every call a space is left for PCLATH to be set if necessary.
Sometimes two instructions are needed for this, because PCLATH needs to access four pages. After two linker passes, the final procedure is shaped and placed in ROM.
However, your procedure has so many calls to LCD_OUT that before and after every one of those calls PCLATH needs to be set, for it is located in different page.
PIC18 family microcontrollers only have a bigger page, but the problem mechanism is the same. Your code can be successfully optimized so that it can run with no problems on PIC16F877A.

Best regards,

Losic Tihomir
mikroElektronika [Support team]

arvinfx
Posts: 115
Joined: 22 Feb 2010 18:44

Re: ROM memory full?

#3 Post by arvinfx » 22 Jul 2023 20:48

tihomir.losic wrote:
27 Dec 2010 13:26
Hello,

The problem here is that the size one of your functions is too big that it cannot be successfully fitted into a single page of PIC16F877A.
The page limit is 2K and your function alone was 1859 addresses long. Because it calls other procedures on other pages, PCLATH has to be set in order for it to access
the page with the destination called procedure. Because linker doesn't know how everything will turn out to be at the end,
the pessimistic approach is implemented so that before every call a space is left for PCLATH to be set if necessary.
Sometimes two instructions are needed for this, because PCLATH needs to access four pages. After two linker passes, the final procedure is shaped and placed in ROM.
However, your procedure has so many calls to LCD_OUT that before and after every one of those calls PCLATH needs to be set, for it is located in different page.
PIC18 family microcontrollers only have a bigger page, but the problem mechanism is the same. Your code can be successfully optimized so that it can run with no problems on PIC16F877A.

Best regards,

Losic Tihomir
Dear losic
I have same problem with same PIC16F877A ! Exactly more than 1900 bytes code will compile but never works fine and i have random reset and faulty reactions if more than 1900 bytes!

I have read this topic and also datasheets and now i know the problem issue .
But, What is the solution in mikeoBasic IDE ?

I have a large ( Main ) code near 300 lines and some sub procedures.

Post Reply

Return to “mikroBasic PRO for PIC General”