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 support@ccsinfo.com

OSCCAL and compiler version 2.706

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







OSCCAL and compiler version 2.706
PostPosted: Mon Feb 16, 2004 10:08 pm     Reply with quote

Hi all, I am working on a project which uses a 12c672 chip. I have version 2.706 of the CCS compiler. Digging through the archives of this board I discovered that a problem with OSCCAL was fixed in 2.708 of the compiler. Does anyone know what the fix was? My assembly output of the call to the OSCCAL calibration looks likes this after I compile the code:

Code:

0000  3000          movlw  0x0                           
0001  008A          movwf  0xA                           
0002  2828          goto   0x28                         
.
.
.       // serveral lines of assembly
.
.
0028  3007          movlw  0x7                           
0029  008A          movwf  0xA                           
002A  27FF          call   0x7FF                         
002B  0085          movwf  0x5                           
002C  3000          movlw  0x0                           
002D  008A          movwf  0xA                           
002E  287A          goto   MAIN                         


Does it look correct? If not what should I do to fix it?

Thanks
Doug
Felix Althaus



Joined: 09 Sep 2003
Posts: 67
Location: Winterthur, Switzerland

View user's profile Send private message

PostPosted: Tue Feb 17, 2004 6:36 am     Reply with quote

Hello

I don't remeber how much ROM the 672 has, but if it's 2048 words, your code seems to be correct (if there is a 'RETLW XX' instruction at address 0x7FF).

Felix
Doug
Guest







PostPosted: Tue Feb 17, 2004 9:55 am     Reply with quote

Ok, good Very Happy . Its a 2K rom, I just wasn't sure if there was a change made which affected the loading of the OSCCAL register.

Thanks,
Doug
Felix Althaus



Joined: 09 Sep 2003
Posts: 67
Location: Winterthur, Switzerland

View user's profile Send private message

PostPosted: Tue Feb 17, 2004 10:21 am     Reply with quote

Hello Doug

I'm very sorry but I think I have overlooked something:

Your compiler stores the osccal value in the register 0x05 but that's the GPIO. Can you have a look at the PIC12c672 output of the picchips program? What does it say about the osccal register location?
If the fault is there, perhaps you can correct it with the device table editor. If you don't have one you can use this code (as I do):

#byte OSCCAL = 0x8F

// somewhere at the beginning of main():
OSCCAL = YOUR_VALUE;

The compiler should handle the bank switching automatically.

Felix
Doug
Guest







PostPosted: Tue Feb 17, 2004 11:12 am     Reply with quote

Ahhh... yes, the data sheet says the OSCCAL value is at 8F. I thought it was kind of strange that the value got writen to 05 but I figured it was due to bank selection.

So if I program multiple chips can I do my own routine at the beginning like:
Code:

#byte OSCCAL = 0x8F



main(){

// initialization code

#asm
          movlw  0x07                           
          movwf  0x0A                           
          call   0x7FF                         
          movwf  OSCCAL                           
          movlw  0x00                           
          movwf  0x0A                           
#endasm

// rest of program

}


Can I put that in my code to fix the problem?

Thanks,
Doug
Felix Althaus



Joined: 09 Sep 2003
Posts: 67
Location: Winterthur, Switzerland

View user's profile Send private message

PostPosted: Tue Feb 17, 2004 1:19 pm     Reply with quote

Yes that's possible, but I don't know if the compiler accepts a #byte-definition within assembly code. Perhaps you have to define OSCCAL with:

#define OSCCAL 0x8F

Perhaps you also have to switch to the correct bank (and back) before moving the return value to OSCCAL.

Felix
Doug
Guest







PostPosted: Tue Feb 17, 2004 1:46 pm     Reply with quote

Ok, according to the data sheet I only have to set bit 5 of register 3 (status register) to switch banks. But what does putting 0x07 into PCLATH (0A) before the call to 0x7FF do? Is this another form of bank switching? I'm confused about the use of banks.

Thanks,
Doug
Felix Althaus



Joined: 09 Sep 2003
Posts: 67
Location: Winterthur, Switzerland

View user's profile Send private message

PostPosted: Tue Feb 17, 2004 3:15 pm     Reply with quote

Hi

The 0x07 into PCLATH is the "page switch" so the PIC can access the upper program memory pages (in this case the highest one where the retlw XX lies).

Have a look at the datasheet.


Felix
Doug
Guest







PostPosted: Tue Feb 17, 2004 3:36 pm     Reply with quote

Thanks Felix!

I didn't know "page switch" and "bank select" were two different things. I need to learn more. Confused

I'll look into it.
Doug
Guest







PostPosted: Tue Feb 17, 2004 5:47 pm     Reply with quote

Ok I think I have it now.....

Here's what I did:
Code:

#define OSCCAL 0x8f
.
.
.
.
main(){

// initialization code here

#asm
   movlw  0x07                           
   movwf  0x0A                           
   call   0x7FF                         
   movwf  OSCCAL                           
   movlw  0x00                           
   movwf  0x0A                           
#endasm

// rest of program



And here is what it looks like after I compiled it:
Code:


          movlw  0x7                           
          movwf  0xA                           
          call   0x7FF                         
          bsf    0x3,0x5                       
          movwf  0xF                           
          movlw  0x0                           
          bcf    0x3,0x5                       
          movwf  0xA                           



Notice how CCS took care of the bank selection bit automatically. Now when I run MPLAB Simulator it updates the OSCCAL register properly.

Thank you Felix, for helping me with this work around.
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