CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC16F636 wrong bank switch

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest
Guest







PIC16F636 wrong bank switch
PostPosted: Wed Feb 23, 2005 5:17 am     Reply with quote

This is the copy of the list file at the very begining of my program using 16F636
[list] ROM used: 915 words (45%)
Largest free fragment is 1133
RAM used: 15 (12%) at main() level
21 (16%) worst case
Stack: 3 worst case (2 in main + 1 for interrupts)

*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 031
0003: NOP
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 23
0008: MOVF 7F,W
0009: MOVWF 22
000A: MOVF 0A,W
000B: MOVWF 27
000C: CLRF 0A
000D: SWAPF 22,F
000E: MOVF 04,W
000F: MOVWF 24
0010: MOVF 20,W
0011: MOVWF 25
0012: MOVF 21,W
0013: MOVWF 26
0014: BCF 03.7
0015: BCF 03.5
0016: BTFSS 0B.4
0017: GOTO 01A
0018: BTFSC 0B.1
0019: GOTO 258
001A: MOVLW 8C
001B: MOVWF 04
001C: BTFSS 00.0
001D: GOTO 020
001E: BTFSC 0C.0
001F: GOTO 25B
0020: BTFSS 0B.5
0021: GOTO 024
0022: BTFSC 0B.2
0023: GOTO 25E
0024: MOVF 24,W
0025: MOVWF 04
0026: MOVF 25,W
0027: MOVWF 20
0028: MOVF 26,W
0029: MOVWF 21
002A: MOVF 27,W
002B: MOVWF 0A
002C: SWAPF 23,W
002D: MOVWF 03
002E: SWAPF 7F,F
002F: SWAPF 7F,W
0030: RETFIE
0031: MOVLW 07
0032: MOVWF 0A
0033: CALL 7FF
0034: BSF 03.5
0035: MOVWF 10
0036: MOVLW 00
0037: MOVWF 0A
0038: GOTO 370[/list
][/b]

in the row 34. compiler set wrong bank and my program after row 38. jump to 770 instead of 370 using CCS Version 3.212

If any solution I would be Smile
HUNLaci
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 23, 2005 1:29 pm     Reply with quote

Can you post a short program that demonstrates that bug ?
I'll test it with 3.219 and see if CCS fixed it in that version.
Guest
Guest







PostPosted: Thu Feb 24, 2005 2:09 am     Reply with quote

The simplest code produce the effect:
Code:
#include <16F636.h>
#use delay(clock=4000000)
#fuses NOWDT,INTRC_IO, NOPROTECT, NOCPD, MCLR, NOIESO, PUT, NOFCMEN, NOWURE, NOBROWNOUT

#int_TIMER0
TIMER0_isr()
{

}

void main()
{

   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_TIMER0);
   enable_interrupts(GLOBAL);
    while(1){
   
    }

}

HUNLaci
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 24, 2005 2:47 am     Reply with quote

Here's the code for main() that's produced by PCM vs. 3.219. This would
correspond to the code in your program, at addresses 0x31 to 0x38.
Notice that the new code doesn't try to call 0x7FF. That's because in
version 3.212, I think that CCS was confused about the internal oscillator.
They are trying to read the OSCCAL value, as in the 12F675, but the
16F636 doesn't have an OSCCAL register. The data sheet says the
oscillator is "factory tuned" which might mean that it's laser trimmed,
or something like that. Anyway, in 3.219, they have fixed that bug.

Code:

// Code produced by vs. 3.219:
.................... void main()   
.................... {   
002A:  CLRF   04         // Clear FSR
002B:  MOVLW  1F
002C:  ANDWF  03,F    // Clear the bank select bits.
002D:  MOVLW  07      // Turn off the comparators
002E:  MOVWF  19
002F:  BSF    03.5
0030:  MOVF   05,W    // Read TRISA
0031:  BCF    03.5
0032:  MOVF   19,W    // Read CMCON0
0033:  BCF    0C.3    // Clear C1IF
....................   



I looked a little bit closer at your complaint, and I don't think there's
a problem as you describe it. Line 34 is setting the RP0 bit. That
affects the RAM bank, not the program counter address. So it won't
affect the jump address. In lines 36 and 37, your program is moving
0x00 into PCLATH. So it should jump to the address specified in the
opcode, which is 0x370. Did you actually see it jump to 0x770 ?

I think it's possible that if you report the OSCCAL bug to CCS, they
might give you a 1-day extension of your download rights and let you
download vs. 3.219. You should email CCS tech support about it.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group