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

problem with timers of PIC in CCS

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



Joined: 12 Oct 2008
Posts: 7

View user's profile Send private message

problem with timers of PIC in CCS
PostPosted: Sun Oct 12, 2008 7:16 am     Reply with quote

hi,
I am a new user of CCS and have problem with timers. I don't know how to use timer libraries. I don't know how to start timer, stop timer and save timer number in a variable. Please help me on the code below that don't work correct to correct, the counter of this code work properly but the formula answer is 0 I think the timer don't work correctly: very thanks.
Code:

void main()
{
long int x,a,b;
long int y,c;
float s,z;
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_256);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
   setup_timer_2(T2_DIV_BY_16,255,16);

main:
{
#define timer1

    if( input(PIN_B4) )
    y=y+1;
    c=y;
    set_timer1(0);
    if (y==11);
    y==0;
    z=timer1
    s=(10.0/z);
    set_timer1(0);
    printf(" count :   %f    m/s \n\r" ,z);
    goto main;
     }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Oct 12, 2008 11:21 am     Reply with quote

Use Google to find tutorials on using the PIC Timers.

Timers: What you should know
http://www.ccsinfo.com/forum/viewtopic.php?t=22467

Microchip -- Timers Tutorial
http://ww1.microchip.com/downloads/en/DeviceDoc/51682A.pdf

Microchip -- Timers: Timer0 Tutorial (Part 2)
http://ww1.microchip.com/downloads/en/DeviceDoc/51702A.pdf
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