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

12f683 intrc_io doesn't work

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



Joined: 07 Mar 2007
Posts: 2

View user's profile Send private message

12f683 intrc_io doesn't work
PostPosted: Fri Mar 09, 2007 12:48 am     Reply with quote

I am using a 12f683 and want to run the pic on its internal osc while using GP4&5 as IO pins. If I set the fuses to any XT,LP, or HS and have the fail safe clock montior fuse set (FCMEN) the pic will detect no external osc and run on its internal osc. However when I set the fuse to intrc_io (or any internal osc configuration) the pic dosnt run at all. I have tried other 12f683 and had the same results. I also tried setting the config bits myself using #rom = .... (commented out in code) and had the same results. I saw a few posts suggesting another fix for other versions of compilers and tried that also with no luck (#rom 0x7ff = {0x3400}) I have included the code I am running. Can anyone suggest why this is happen or what I have done wrong??

Thanks

Compiler version 3.202

#include <12F683.h>
#device adc=8
#fuses WDT,INTRC_IO, NOCPD, NOPROTECT, MCLR, NOPUT, BROWNOUT, IESO, FCMEN
//#rom 0x2007 = {0x0bfc}
//#rom 0x7ff = {0x3400}
#use delay(clock=8000000)

#byte tris = 0x85 //GP tris for 12f683
#byte port = 0x05 //GP port for 12f683


void main() {

setup_oscillator(OSC_8MHZ);
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
tris=tris&0x00;

while (true){
restart_wdt();
delay_ms(200);
port=0xff;
delay_ms(200);
port=0x00;
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 09, 2007 1:10 am     Reply with quote

Quote:

However when I set the fuse to intrc_io (or any internal osc
configuration) the pic doesn't run at all.


The data sheet says it only applies to external oscillators:
Quote:

3.7 Fail-Safe Clock Monitor

The FSCM function is enabled by setting the FCMEN
bit in the Configuration Word register (CONFIG). It is
applicable to all external clock options (LP, XT, HS, EC,
RC or IO modes).

In the event of an external clock failure, the FSCM will
set the OSFIF bit (PIR1<2>) and generate an oscillator
fail interrupt if the OSFIE bit (PIE1<2>) is set. The
device will then switch the system clock to the internal
oscillator. The system clock will continue to come from
the internal oscillator unless the external clock recovers
and the Fail-Safe condition is exited.
brad2279



Joined: 07 Mar 2007
Posts: 2

View user's profile Send private message

PostPosted: Fri Mar 09, 2007 12:32 pm     Reply with quote

Thanks for the response

I was only using the fail-safe clock monitor to test if the internal osc is actually working or not (this confirmed that the internal osc is working). So now I want to use the internal osc with the two clock pins as IO but when I set the fuse to INTRC_IO the device does not run at all. I have tried this with the fail safe clock diasable as follows;
#fuses WDT,INTRC_IO, NOCPD, NOPROTECT, MCLR, NOPUT, BROWNOUT, IESO, NOFCMEN
and still no luck. I have also tried with the WDT, brownout detection and the mater clear pin disabled, and still no sucsess. What I need is to be able to use the clock pins as IO so the device needs to be set to run on its internal osc but as I said befor whenever I try to configure the device this way it stops running.

I did poll the PIR1<2> and indeed it is set when I use the fail safe monitor and configure the device to run on external osc (HS,LP,etc)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 09, 2007 1:33 pm     Reply with quote

Try a simple program. See if this one will blink Pin A0.
Code:
include <12F683.h>
#fuses INTRC_IO, NOWDT, PUT, BROWNOUT
#use delay(clock = 8000000)

#rom 0x7FF = {0x3400}  // Needed for vs. 3.202

//========================================
void main()
{
setup_comparator(NC_NC_NC_NC);  // Needed for vs. 3.202
setup_adc(ADC_OFF);             // Needed for vs. 3.202

while(1)
  {
   output_high(PIN_A0);
   delay_ms(500);
   output_low(PIN_A0);
   delay_ms(500);
  }

}
Guest








PostPosted: Mon Mar 12, 2007 7:06 pm     Reply with quote

that test program does work. Thanks for that, but what did I do wrong with my previous test program? I will contiue to play around with the code and see if I can pick out where I went wrong.

Thanks your responses were very fast and helpful
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