Jump to content

Recommended Posts

I use a PIC16F1847 and the BoostC compiler.

 

I wrote some code which uses 14 bytes of data. Now I have to do the same code but for another data record. I started by writing the same function twice, one for the first data record and

the other for the second data record. Because I only have 14 bytes of data but much more code I thought it is better using a pointer, then it is much easier to expand it later too.

 

So I thought, no problem, just put it in two arrays or structures and pass a pointer. But there is a problem, now the code size is blown up in a way that the memory of the pic is too small,

before I used about 30% for this and now 60%. So the code size is nearly doubled by using pointers instead of writing the same code twice. With my other code now I am at about 90%

but the software is not yet ready. I also tried to use linear addressing, but the code size is nearly the same.

 

Because I only have 2 data records with 14 bytes each, I thought, why not using the banking mechanism of the pic by placing every record at the same address but in another bank.

May be that the compiler is intelligent enough to detect this and to generate code which don't use the MOVLB instuction but moves the content of a variable to the BSR register

(MOVF BANK,W, MOVWF BSR). All local variables can be doubled too, the data memory size is not the problem. This will not blow up the code size because every function only

has to set the BSR once if not using data of another bank.

 

Is there a way to do this? Or is there another possible solution?

 

Best regards,

 

Albert

Share this post


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...
Sign in to follow this  

×
×
  • Create New...