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

Pic12F675 internal oscillator ...

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







Pic12F675 internal oscillator ...
PostPosted: Sun Mar 23, 2008 4:13 am     Reply with quote

My program is
#include <12f675.h>
#fuses xt,nowdt,noput,protect
#device adc=10
#use delay (internal=4M) // naudojame vidini generatoriu

int16 volt;
float rod;

#define gedim pin_A4
#define aliarm pin_A5
#define resetas pin_A1
#define statusas pin_a2

void duomenys()
{
volt = read_adc();
rod = volt; //1k = 23 2.2k = 11 470 om = 48 5.6k = 4 4.7k = 5
} //suveikias daviklis = 74 trumpas jungimas = 190 100 om = 162
//Ishvados 0 - 5 = nutrukes, 5 - 30 = normalu, 30-150 = suveikes 150< = trumpas
void trumpas()
{
trump:
output_low(gedim);
output_low(resetas);
delay_ms(1000);
output_high(resetas);
duomenys();
if (rod>150) goto trump; else output_high(gedim);
}
void aliarmas()
{
output_high(statusas);
output_low(resetas);
delay_ms(3000);
output_high(resetas);
delay_ms(3000);
duomenys();
if (rod>30 & rod<150)
{
alr:
output_high(aliarm);
delay_ms(100);
duomenys();
if (rod>150) trumpas();
if (rod>30 & rod<150) goto alr; else { output_low(aliarm);output_low(statusas);}
}
}
void gedimas()
{
ged:
output_low(gedim);
delay_ms(1000);
duomenys();
if (rod<5) goto ged; else output_high(gedim);
}
void main() //Pagrindine programa
{
delay_ms(100);
disable_interrupts(GLOBAL);
setup_adc_ports(pin_A0);
setup_adc(ADC_CLOCK_DIV_8);
set_adc_channel(0);
output_high(resetas);
output_low(statusas);
output_high(gedim);
output_low(aliarm);
delay_ms(2000);
while(1)
{
duomenys();
delay_ms(100);
if (rod<5) gedimas();
if (rod>30 & rod<150) aliarmas();
if (rod>150) trumpas();
}
}


===
I rewrited chip about 8 times and chip stops, not working with internal oscillator, but with external oscillator it working.
where can be a problem ?
ty.
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

oscilator
PostPosted: Sun Mar 23, 2008 7:55 am     Reply with quote

i can't check with 12F675.
i test it with 18f1220. have also internal oscilator.
i get:
#FUSES INTRC //Internal RC Osc
#use delay(clock=4000000)
maybe the compiler don't understand:
#use delay (internal=4M)
best regards
joseph
Ttelmah
Guest







PostPosted: Sun Mar 23, 2008 8:02 am     Reply with quote

The most likely thing is that the chip has been erased.....
On these PICs, there is a _single_ program instruction, in the very last location of the program memory, which returns the calibration factor for the internal oscillator. Most programmers have an _option_ to save this value when you program the chip. Otherwise, if an erase cycle is performed, this value _will_ be destroyed, and the chip will then hang if you try to run with the internal oscillator.
Read the contents of the chip's program memory.
Look at the very last instruction.
If it is blank (erased), then you will need to write a value back into this location. This can be done with a #ROM statement, but the value will then no longer be calibrated, so if you want anything reasonable in terms of clock accuracy, some 'tweaking' will be needed. A search here will find the values you need to write to get it to start (many people, myself included have posted them in the past).

Best Wishes
Radistas
Guest







PostPosted: Mon Mar 24, 2008 1:47 am     Reply with quote

Ty, it was calibration bit, i set it to 3480 and it's working.
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