manuel123 0 Posted October 3, 2007 Report Share Posted October 3, 2007 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 Quote Link to post Share on other sites
Dave 0 Posted November 11, 2007 Report Share Posted November 11, 2007 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 Quote Link to post Share on other sites
manuel123 0 Posted November 12, 2007 Author Report Share Posted November 12, 2007 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 Quote Link to post Share on other sites
manuel123 0 Posted November 15, 2007 Author Report Share Posted November 15, 2007 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 Quote Link to post Share on other sites
Dave 0 Posted November 15, 2007 Report Share Posted November 15, 2007 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 Quote Link to post Share on other sites
manuel123 0 Posted November 15, 2007 Author Report Share Posted November 15, 2007 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 Quote Link to post Share on other sites
Recommended Posts
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.