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

10F206 calibration issues with #rom

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



Joined: 12 Nov 2005
Posts: 7

View user's profile Send private message

10F206 calibration issues with #rom
PostPosted: Thu Aug 12, 2010 11:01 am     Reply with quote

Hi all,
Some time ago I erased my osccal value. I thought it would be an easy thing to fix so I replaced it with :

#rom 0x1FF = {0xC00} // Put MOVLW 0x00 at last address of ROM

Then I discovered that this was not good enough. At location 0x204 is a backup calibration. The Data Sheets say zippo! Microchip Forum mentions this address, melabs U2 Programmer can read it and Microchip ICD-3 complains with an error message if all is not right.

I think both locations need to be the same or else the backup calibration is used but I could not verify this.

I ran some tests with a frequency counter and determined my best osccal value is between 5 and 6. I picked 6 because I like seeing 1.00nnn better on my Freq counter.

Then I revised my program to change both the primary and backup osccal.

My problem is the #rom command only works every once in a while!! I know this to be true by changing the osccal value form 5 to 6 and back again.

My hardware environment is the EDTP Little Bits board with a ICD-U40 and Software rev 4.110. No warnings no errors.

It's amazing I can not be master of such a small device.

Regards
Tim C



Code:

#include <10F206.h>

#FUSES NOWDT                     //No Watch Dog Timer
#FUSES MCLR                      //Master Clear pin enabled
#FUSES NOPROTECT                 //Code not protected from reading
//#DEVICE ICD=TRUE                // ICD is not available on the 10F206

// Calibration of 6 determined by Freq Counter on GP2/B2     0C = 6 << 1
//#rom 0x204 = {0xC0C}                // Put MOVLW 0x0C at Backup Calibration Spot
//#rom 0x1FF = {0xC0C}                // Put MOVLW 0x0C at end of ROM Primary calibration


#use delay(clock=4M)
#byte osccal = 0x05            // Tweaking this is easy
#bit FOSC4 = 0x05.0            // Shared with osccal

#define LED1    PIN_B0
#define LED2    PIN_B1
//#define LED3    PIN_B2         // PIN_B2 is also Freq out so use one of the other

void main() {

   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
   setup_comparator(NC_NC);
   //osccal = 6 << 1;      // This works great but #rom 0x0CNN does not always work!!
   FOSC4 = 1;            // turn on the Freq out so I can calibrate on Freq counter

    while(TRUE) {
        output_high(LED1);    // turn on LED
        delay_ms(100);           // lets delay.
        output_low(LED1);     // turn off LED
        output_high(LED2);    // turn on LED
        delay_ms(100);           // lets delay.
        output_low(LED2);     // turn off LED
        //output_high(LED3);    // turn on LED comment when using FOSC4
        delay_ms(100);           // lets delay.
        //output_low(LED3);     // turn off LED comment when using FOSC4
    }

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Aug 12, 2010 11:51 am     Reply with quote

Quote:
My problem is the #rom command only works every once in a while!!

What's more likely is that your programming software won't let you
program the Calibration data location. In MPLAB, for the ICD3, go to
the Programmer/Settings menu and look at the Calibration Memory tab.
You have to select a tickbox to allow it to program the Calibration
Memory.

But do you have to use #rom ? That MPLAB tab in the Settings menu
allows you to enter a new Calibration value.

Quote:

At location 0x204 is a backup calibration. The Data Sheets say zippo!

This type of information will be in the Programming Guide. Every PIC
has a Programming Guide. The best way to find it, is to type in the full
name of the PIC into Google, such as PIC10F206. The first hit will take
you to the Microchip page for that PIC. The programming guide is
downloadable from there. Here it is for the 10F206:
http://ww1.microchip.com/downloads/en/DeviceDoc/41228E.pdf
Look in this section on page 2:
Quote:

2.5 Backup OSCCAL Value


Having said all of this, I still agree that it can be a pain to make it all
work. I had this problem a few months ago and it took me several tries
using MPLAB and an ICD2, to get it to work. I don't want to volunteer
to erase my Calibration data in a PIC, just to test it out again. Once was
enough.
TimC



Joined: 12 Nov 2005
Posts: 7

View user's profile Send private message

PostPosted: Thu Aug 12, 2010 1:42 pm     Reply with quote

Thank You!
Learned a lot. MPLAB is the way to go. Worked the first time, second time, and third time.

Not sure what to do if you don't have a Microchip ICD2 or 3.
Regards
Tim C
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