View previous topic :: View next topic |
Author |
Message |
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
PIC12F508 gives different times |
Posted: Wed May 23, 2018 10:35 am |
|
|
When I use MPLAB to program the chip I get the message Quote: | The target has invalid calibration data (fff). | then when I try to program the chip I get this message: Quote: | The following memory regions failed to program correctly:
Program Memory
Address: 00000000 Expected Value: 00000025 Received Value: 00000000
Programming failed |
Therefore I used different tool for programming: With that tool I am able to program the chip but I get different pulse times every next programming. My application will rely on correct timings so how to calibrate the chip?
This is a code sample for the test:
Code: |
void main() {
#include <12F508.H>
#fuses INTRC, NOWDT, NOPROTECT, NOMCLR
#USE DELAY (int = 4MHZ)
while(1) {
delay_us(10);
output_toggle(PIN_B5);
}
}
|
With the code above I get different periods with each new flashing. Once i get 20uS then 22us and so on. _________________ A person who never made a mistake never tried anything new. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19550
|
|
Posted: Wed May 23, 2018 10:49 am |
|
|
What has happened is that at some point you have done a full erase, and lost the OSCCAL value.
Now the older PicKit2, did have an option to recalculate this value.
Some of the CCS programmers have a similar option.
Without this option you have to manually generate the value. Read what has been put into the top instruction in the ROM (it'll be a RETLW xx) instruction. Then the data sheet gives how much the clock changes for changes in this value. Calculate a new value program this and test. You'll probably have to tweak it a few times till you can get the value reasonably correct. |
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Wed May 23, 2018 11:50 am |
|
|
Thank you for your response. Could that value be something like 25 (like the expected value from my second quote). Isnt the compiler that generates the instructions including the one that is on the top? _________________ A person who never made a mistake never tried anything new. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed May 23, 2018 12:44 pm |
|
|
What version of MPLAB are you using ? MPLAB vs. 8.92 or MPLAB X vs. ? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19550
|
|
Posted: Wed May 23, 2018 1:10 pm |
|
|
The value is not a value in simple time like that it is a 'tweak' factor applied to the default oscillator. +/- a few percent. The mid value will give a particular speed and you will then have to calculate the percentage this needs to move. |
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Thu May 24, 2018 2:04 am |
|
|
@PCM programmer
The MPLab version is 8.89.
@Ttelmah:
Could you please explain little bit more detailed how can I change the "top instruction in the ROM"?
https://drive.google.com/file/d/1k7VQfS90tF2b_Grf2v6HqnLiMRe8ZX8P/view?usp=sharing
Can I change value from the pic above? Is that what you meant?
Furthermore I see that the compiler provides the user to write custom data into the rom using directives: . May be this could do the job too? _________________ A person who never made a mistake never tried anything new. |
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Thu May 24, 2018 2:20 am |
|
|
@PCM programmer
The MPLab version is 8.89.
@Ttelmah:
Could you please explain little bit more detailed how can I change the "top instruction in the ROM"?
https://drive.google.com/file/d/1k7VQfS90tF2b_Grf2v6HqnLiMRe8ZX8P/view?usp=sharing
Can I change value from the pic above? Is that what you meant?
Furthermore I see that the compiler provides the ability for user to write custom data into the rom using directives: . May be this could do the job too?[/quote] _________________ A person who never made a mistake never tried anything new. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu May 24, 2018 2:51 am |
|
|
rikotech8 wrote: | @PCM programmer
The MPLab version is 8.89.
|
Go to the following menu:
Quote: | Programmer / Settings / Calibration Memory tab |
There you can click a tickbox that says:
Quote: | Allow Pickit 3 to program Calibration Memory |
You can put in the new value you want for Calibration memory
into the textbox to the right of "movlw".
Then program your 12F508.
It's possible that when you're done, you should go back and de-select
that tickbox. I don't know if MPLAB de-selects it automatically after
one use. |
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Thu May 24, 2018 9:24 am |
|
|
@PCM programmer: Thank you for your response. I checked the checkbox for Quote: | Allow PICkit3 to program calibration memory | but when hit the program button I still get the error: Quote: | Programming...
The following memory regions failed to program correctly:
Program Memory
Address: 00000000 Expected Value: 00000025 Received Value: 00000000
Programming failed |
The only way the programming goes well is when I first read the device and then program the chip(i guess is because it reads every word it write), otherwise I get the error above.
Although I am able to flash the chip with this tool <http://ww1.microchip.com/downloads/en/DeviceDoc/PICkit3%20Programmer%20Application%20v3.10.zip > _________________ A person who never made a mistake never tried anything new. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19550
|
|
Posted: Thu May 24, 2018 12:48 pm |
|
|
And the Pickit2 software offers an option to automatically regenerate the calibration value. Much nicer... |
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Fri May 25, 2018 1:06 am |
|
|
Thank you guys. Buying another PIC12 is relatively less expensive than buying PICKit2. So I will throw away 12f508 and buy other PIC. _________________ A person who never made a mistake never tried anything new. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19550
|
|
Posted: Fri May 25, 2018 1:32 am |
|
|
Assuming you have got PCM, and not just PCB, then chips like the 12F1840 are a 'world apart' from the 508. Comparator, DSM, UART, CPS, DAC, MSSP, PWM etc. etc.. 8* the ROM, and 10* the RAM!...
The core is actually a PIC16 (hence needs PCM), but sold as a PIC12, and put into a 8 pin package.
If you want a little 8pin PIC, these are great for almost every such job. Now they cost almost twice as much, but are just a better chip in just about every way.... |
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Fri May 25, 2018 3:23 am |
|
|
Yes of course! There are two considerations for my project.
The first one is that the chip must comply with the schematics(which is already printed), hence the pinout should be the same as those on 12F508.
The second is the time for implementation. Should be as quick and easy as possible, hence less investment, hence the profit gets bigger.
So in instead of ordering chips that are superior and cost more than 12f683, I decide to use this one, which I have in place, complies the requirements and allows me to start working immediately.
So I completely agree there are better uCs, but the applications requires just as much as this chip provides, even less - it is quite simple application.
You helped me a lot for the next time choice of uC. The oldest doesn't seem to be good ones. _________________ A person who never made a mistake never tried anything new. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19550
|
|
Posted: Fri May 25, 2018 6:24 am |
|
|
Yes. The problem is that sometimes the older chips are not properly supported by the newer tools. This is why keeping hold of older tools is so useful... |
|
|
|