Jump to content
Sign in to follow this  
manuel123

Bug: Bank Switching

Recommended Posts

Bug description:

If the array length is 80 in the following example, bank switching fails.

If the array length is 79, bank switching works fine.

 

Steps to reproduce:

-----------------------

 

#include <system.h>

 

unsigned char var[80]@0x20;

unsigned char i;

 

void main()

{

portb.1 = 0;

 

for (i=0; i<2; i++) {

if (i==0) trisb.1 = 1;

else trisb.1 = 0;

}

}

 

 

Expected behaviour:

This is the asm code for array length 79 (correct code). The two marked lines are missing when array length is 80.

 

main

; { main ; function begin

BCF STATUS, RP0

BCF STATUS, RP1

BCF gbl_portb,1

CLRF gbl_i

label268438904

MOVLW 0x02

SUBWF gbl_i, W

BTFSC STATUS,C

RETURN

MOVF gbl_i, F

BTFSS STATUS,Z

GOTO label268438908

BSF STATUS, RP0 <------- missing when array length is 80

BSF gbl_trisb,1

GOTO label268438911

label268438908

BSF STATUS, RP0

BCF gbl_trisb,1

label268438911

BCF STATUS, RP0 <------- missing when array length is 80

INCF gbl_i, F

GOTO label268438904

; } main function end

 

 

Is the problem 100% reproduceable:

Yes.

 

IDE version: 6.81

Compiler: BoostC,

Compiler version: boostc.pic16.exe / v6.81

Target device: PIC16F88

OS: WinXP SP2

 

BR

manuel123

Share this post


Link to post
Share on other sites
Bug description:

If the array length is 80 in the following example, bank switching fails.

If the array length is 79, bank switching works fine.

The banks switching is CORRECT in both cases. When the array length is increased, the i variable ends up being placed into memory that appears in all banks, so no banks switching is required to access this variable.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Dave, thanks for the reply. The problem is not the variable i but trisb which is available only in bank 1. There must be a

 

BSF STATUS, RP0

 

somewhere in the code!

 

Regards

Manuel

 

Bug description:

If the array length is 80 in the following example, bank switching fails.

If the array length is 79, bank switching works fine.

The banks switching is CORRECT in both cases. When the array length is increased, the i variable ends up being placed into memory that appears in all banks, so no banks switching is required to access this variable.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Compile the code for array length 80 and step though it with the debugger. RP0 is cleared at program start and will never be set before you arrive at

 

BSF gbl_trisb,1

 

So, portb is accessed with this instruction, not of trisb.

 

BR

manuel123

 

 

Dave, thanks for the reply. The problem is not the variable i but trisb which is available only in bank 1. There must be a

 

BSF STATUS, RP0

 

somewhere in the code!

 

Regards

Manuel

 

Bug description:

If the array length is 80 in the following example, bank switching fails.

If the array length is 79, bank switching works fine.

The banks switching is CORRECT in both cases. When the array length is increased, the i variable ends up being placed into memory that appears in all banks, so no banks switching is required to access this variable.

 

Regards

Dave

Share this post


Link to post
Share on other sites
Dave, thanks for the reply. The problem is not the variable i but trisb which is available only in bank 1. There must be a

 

BSF STATUS, RP0

 

somewhere in the code!

Yes you are right there is a problem here, it has been made apparent because this target has some unbanked memory.

 

This is now fixed and will be in the next release.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Thank you very much!

 

Dave, thanks for the reply. The problem is not the variable i but trisb which is available only in bank 1. There must be a

 

BSF STATUS, RP0

 

somewhere in the code!

Yes you are right there is a problem here, it has been made apparent because this target has some unbanked memory.

 

This is now fixed and will be in the next release.

 

Regards

Dave

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...