Code size make me problem!

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
arvinfx
Posts: 115
Joined: 22 Feb 2010 18:44

Code size make me problem!

#1 Post by arvinfx » 22 Jul 2023 15:52

Hi, I am trying to write a code on PIC16F877A .
My code works if size of code is less than 1924 bytes which is 23% of total ROM, but if i add a small code like i=1 compiler makes my code 1986 bytes (24%) and my code works wrongly randomly reset or variable changes randomly !!!!!! Also I realized that when code is bigger or equal than 1986 the HEX file is spited in 2 parts .

1924 bytes is like this:
From address 0x00-0x787 is my code

1986 bytes is like this:
From address 0x00-0x2A4 is first part of my code
From address 0x2A5-0x7ff is empty
From address 0x800-0xad20 is second part of my code

Fisrt I thought the UART make me this problem in this viewtopic.php?f=97&t=80073 but it is not UART procedure!

Plz help me , What is going on?!

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

Re: Code size make me problem!

#2 Post by arvinfx » 23 Jul 2023 13:52

I have found the problem, This is Paging issue.
GOTO and CALL can not jump more than 11 bits that is 2kword long.So in PIC16Fxxx we have PCLATH register to switch into 4 PAGEs of 8kword memory.
It has to generate and apply by compiler before any GOTO AND CALL and it will ( I checked ASM code ) BUT it works wrongly! why?!?

Post Reply

Return to “mikroBasic PRO for PIC General”