Jump to content

Linker Problems On Pic18f4455


Recommended Posts

Bug description:

I just compiled, linked and ran some code on a PIC18F4455, and noticed some unexpected behaviour in my program. On investigation I found that some of my data (a char[] array) had been stored in the 0x060-0x0ff range. On the PIC18F4455 this range contains SFRS (note details given below)

 

 

Steps to reproduce:

 

declare an array of over 80 bytes:

 

char *SomeArray= " Any of this text stored between 0x80 and 0xFF may be corrupted"

 

compile, link, run debugger and see where your data is.

 

Expected behaviour:

I expect data not to change unless it is modified by my code... :)

 

Is the problem 100% reproduceable:

Yes.

 

IDE version: MPLab 7.34

Compiler: BoostC

Compiler version: 6.30

Target device: PIC18F4455

OS:

 

Comments:

1 - At a guess your linker is only checking the start address for blocks of ram is valid, or only the first n bytes. Ive only seen this problem using long (200 byte) blocks.

 

2 - In my program both high and low priority interrupts are enabled

 

3 - At first glance, the data sheet suggests 0x00-0xff are all General Purpose Registers, this is not true 0x80 - 0xff are SFRs in the access window, i.e. these addresses are mapped to SFRs. See device datasheet fig 5-5 on page 66 for more details.

 

4 - Short term fix for users with similar problems:

char *DontUseThisArea[128] @ 0x80;

 

I think this is a fairly serious issue as it could cause some occasional unexplained and almost entriely undebuggable problems in peoples projects.

Link to post
Share on other sites

wolahr,

 

Steps to reproduce:

 

declare an array of over 80 bytes:

 

char *SomeArray= " Any of this text stored between 0x80 and 0xFF may be corrupted"

 

compile, link, run debugger and see where your data is.

 

Expected behaviour:

I expect data not to change unless it is modified by my code...

 

I don't see this issue.

Please provide a complete small sample program.

 

Regards

Dave

Link to post
Share on other sites

wolahr,

 

I've managed to track down the problem :)

It occurs when a variable straddles banked and unbanked memory.

 

This fix will be available in the next release - which should be in the next few days.

 

Thanks for reporting this issue.

 

Regards

Dave

Link to post
Share on other sites
wolahr,

 

I've managed to track down the problem :)

It occurs when a variable straddles banked and unbanked memory.

 

This fix will be available in the next release - which should be in the next few days.

 

Thanks for reporting this issue.

 

Regards

Dave

 

Hi dave,

 

Thanks for fixing this so quickly

 

Regards

 

Will

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...