View previous topic :: View next topic |
Author |
Message |
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
OSCCAL problem with PIC10F200 |
Posted: Fri Feb 10, 2012 2:09 pm |
|
|
Hello
I'm trying to program a PIC10F200, but appears an error that I can not solve ...
It is the first time I'm programming a PIC10F, so some problems are emerging.
The code is this:
Code: | #include <10f200.h>
#use delay(clock=4000000)
#fuses NOWDT, NOMCLR
void PIC_INIT()
{
set_tris_B(0B0000);
SETUP_TIMER_0(RTCC_INTERNAL|RTCC_DIV_256);
}
void main()
{
long int conta;
output_high(PIN_B0);
output_high(PIN_B1);
while(1)
{
for(conta=0; conta<1; conta++) //on
{
delay_ms(1000);
}
output_low(PIN_B0);
output_low(PIN_B1);
for(conta=0; conta<5; conta++) //off
{
delay_ms(1000);
}
output_high(PIN_B0);
output_high(PIN_B1);
}
} |
Some images from programer and the errors.
Any ideas so I can solve this problem?
Thank you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Feb 10, 2012 2:32 pm |
|
|
This is really a Microchip question. Google their forum for the following
search string and you will get tons of stuff:
Quote: |
site:microchip.com/forums pickit OR pickit2 osccal
|
http://www.google.com/ |
|
|
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
|
Posted: Fri Feb 10, 2012 3:54 pm |
|
|
Problem solved.
Thank you ;). |
|
|
silelis
Joined: 12 Jun 2007 Posts: 68 Location: Poland, podlaskie district
|
|
Posted: Mon Feb 27, 2017 3:56 pm |
|
|
Can You give an information how to solve this problem? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
silelis
Joined: 12 Jun 2007 Posts: 68 Location: Poland, podlaskie district
|
|
Posted: Tue Feb 28, 2017 12:01 am |
|
|
I have tried it.
Also I have followed this Youtube tutorial (both manual and auto mode). Unfortunately the reason is always like on photo.
[img]https://goo.gl/photos/2UJLAzmBvrusjaUG6[/img]
Any chance to recover it? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 01, 2017 4:41 am |
|
|
My advice is, if you have a real Microchip Pickit 2, then register with
Microchip support and open a Trouble Ticket. They will help you. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Wed Mar 01, 2017 5:18 am |
|
|
Now key thing is to start by reading the data sheet:
Quote: |
9.2.5.1 Calibrating the Internal Oscillator
A calibration instruction is programmed into the last
location of program memory. This instruction is a
RETLW XX, where the literal is the calibration value.
The literal is placed in the OSCCAL register to set the
calibration of the internal oscillator. Example 9-1 demonstrates
how to calibrate the internal oscillator.
Note: Erasing the device will also erase the preprogrammed
internal calibration value for
the internal oscillator. The calibration value
must be saved prior to erasing part.
|
Unfortunately you chip has been erased, and has lost this value.
Now the PicKit routine to regenerate this, seems to regenerate the actual calibration constant only, not the RETLW that returns it.
RETLW, is 08xx, where 'xx' is the constant to return.
Your Pickit has given you the constant value as '8B', and written this, but because the 08 has been lost as well, it is still an invalid value...
So, add to your code:
#ROM 0x0FF=0x88B
Then program the chip with this.
What has happened, is that at some point an erase has been done with the chip 'family' set incorrectly. From the PicKit2 manual:
Quote: |
CAUTION
Ensure that the correct Baseline has been selected. These devices do not contain a device ID to confirm device selection. Choosing the wrong Baseline may cause an erasing of the OSCCAL value stored in the last memory location.
|
It is set incorrectly in your picture. The 10F device is a baseline PIC, not a midrange device.
You can always tell by the instruction word length. Devices with a 12bit instruction word are Baseline. 14bit Midrange.
In fact if you set the device family type correctly and then tell the PicKit to generate the OSCCAL value it may well do it correctly... |
|
|
silelis
Joined: 12 Jun 2007 Posts: 68 Location: Poland, podlaskie district
|
|
Posted: Wed Mar 01, 2017 5:46 am |
|
|
Ttelmah wrote: | Now key thing is to start by reading the data sheet:
So, add to your code:
#ROM 0x0FF=0x88B
Then program the chip with this.
What has happened, is that at some point an erase has been done with the chip 'family' set incorrectly. From the PicKit2 manual:
|
Can You explain something. Why 0X88B?
I mean PicKit2 oscal calculation is 0F8B. I understand that "8B" is oscal value. But what with first "8"? Why 8 not other value?
I thought that command should be 0x348B. 34 - RETLW 8B - oscal value?? But I am rather rookie. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Wed Mar 01, 2017 6:02 am |
|
|
The head of the thread refers to a 10F chip. On the 10F, the RETLW instruction is 0x8kk
0x34kk is the RETLW for a midrange PIC, with 14bit memory.
You are looking at the wrong sheet if you are seeing 0x34kk as the instruction. This is a _12bit_ chip, so can't store an instruction above 0xfff....
However I'd still guess if you set the family correctly, the PicKit will do the whole thing correctly and put the right instruction there... |
|
|
silelis
Joined: 12 Jun 2007 Posts: 68 Location: Poland, podlaskie district
|
|
Posted: Wed Mar 01, 2017 6:08 am |
|
|
Yep. The head id for PIC10f but mine is PIC12F ( I did not want to open new thread so I added my question.
So if I understand.
For PIC10 (from thread) the command should be:
Code: | #ROM 0x0FF = 0x88B //where:
0x0FF - rom location - last byte of flash
0x8 - move value to osccal
8B - osccal value (last two digits calculated by PICkit2 Oscal autoregenerate
|
For PIC12F629 (mine) the command should be:
Code: | #ROM 0x3FF = 0x348B //where:
0x3FF - rom location - last byte of flash (have to check if it is last rom adress if other)
0x34 - move value to osccal
8B - osccal value (last two digits calculated by PICkit2 Oscal autoregenerate
|
Do I right? |
|
|
|