rezaf
Joined: 12 Oct 2008 Posts: 7
|
problem with timers of PIC in CCS |
Posted: Sun Oct 12, 2008 7:16 am |
|
|
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;
}
} |
|
|