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

Timer1 as counter.

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



Joined: 21 Apr 2014
Posts: 12
Location: Kefalonia, Greece

View user's profile Send private message

Timer1 as counter.
PostPosted: Mon Apr 21, 2014 3:01 am     Reply with quote

Hi there,
this is my first post so be patient.

I try to collect pulses through the RC0 gate but nothing happens.
The input pulses created from a button with a resistance in pull down connection. And if the pulses >= 1 i want to switch a led on.
It doesn't work for me and i don't know what else i have to do.
I use 4.093 version and the development board ql200.
Here is the code
Code:

#include <16F877A.h>
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES XT                       //High speed Osc (> 4mhz)
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected
#FUSES NODEBUG                  //No Debug mode for ICD
#use delay(clock=4000000)

unsigned int16 a;


void main()
   {
   setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);
   
   while(1)
      {
      set_timer1(0);
      delay_ms(500);
      a=get_timer1();
      if(a>= 1)
      {
      output_high(pin_c7);
      }
      else output_low(pin_c7);
      }
   }
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Apr 21, 2014 6:59 am     Reply with quote

make sure your pic is RUNNING first!

try this in main:
Code:

void main()
   {
 
   while(1)
      {
   
      delay_ms(500);
      output_toggle (pin_c7);
   
      }
   } 


does the pin change every 1/2 second or not??
Ventouza



Joined: 21 Apr 2014
Posts: 12
Location: Kefalonia, Greece

View user's profile Send private message

PostPosted: Mon Apr 21, 2014 8:19 am     Reply with quote

Yes my pic is running but i found my crystal was gone.

So it was a hardware problem. Now with new crystal the program is running perfectly.

Thanks asmboy
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