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

Using TIMER0 with a PIC12F510

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



Joined: 18 Feb 2004
Posts: 16
Location: UK

View user's profile Send private message

Using TIMER0 with a PIC12F510
PostPosted: Fri Nov 30, 2007 9:55 am     Reply with quote

Hello. I want to use a PIC12F510 to produce a rough 4KHz signal using timer 0 but can't seem to get it to work as the compiler keeps saying 'Invalid Pre-Processor Directive' to the line '#INT_RTCC'.
Am I doing something wrong or am I going to need a different PIC?

I'm using the internal 8MHz oscillator.
My compiler version is 3.245.

Thanks, Simon.

main.c
Code:

#include "blah blah blah\main.h"

int8 level4k = 0;
int8 level80 = 0;

#INT_RTCC
void clock_isr()
{
   set_timer0(6);
   if (level4k)
      level4k = 0;
   else
      level4k = 1;

   output_b(level4k);
}

void main()
{

   setup_adc_ports(AN0_AN1_AN2);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_comparator(NC_NC);

   while(1);
}


main.h
Code:

#include <12F510.h>
//#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES IOSC8                  //Internal 8 MHz oscillator.
#FUSES NOPROTECT                //Code not protected from reading
#FUSES MCLR                     //Master Clear pin enabled
//#FUSES RB4                      //B4 is an I/O pin not CLKOUT

#use delay(clock=8000000)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 30, 2007 12:21 pm     Reply with quote

I don't think this PIC has any interrupts. There's no mention of it
in the data sheet.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Fri Nov 30, 2007 2:59 pm     Reply with quote

Yup. This device has a timer/counter but the data sheet shows no interrupt flag going anywhere. Just the ability to ready the timer register. I even tried to use the wizard and it shows no interrupts to be set up.

If you need an interrupt you'll need to select a different part. It stinks but it's called a learning curve.

Ronald
monkeytennis



Joined: 18 Feb 2004
Posts: 16
Location: UK

View user's profile Send private message

PostPosted: Mon Dec 03, 2007 4:29 am     Reply with quote

So I see. Embarassed

I'm not used to these PICs, I mostly use the 18FXXX series. I must have completely overlooked the lack of interrupts!

Thanks very much for your help. Smile
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