kunal5959
Junior Member level 3
I am using LTC1799 IC to generate a clock signal of 1.832 MHz for my project. The fuse settings seem to be right . when i use following code for test i get inaccurate value of delay
# define F_CPU 1843200UL
# define SCLK_ON PORTA|=(1<<PORTA0)
# define SCLK_OFF PORTA&=~(1<<PORTA0)
#define SCLK_tick _delay_us(100)
int main(){
for(;{
SCLK_OFF; SCLK_tick ;
SCLK_ON; SCLK_tick ;
}
}
For the above code i get a clock signal with period as 214 us instead of 200 us. Is it due to the fact that _delay_us() is not working properly, clock is not set properly in code, fuse settings or a deviation of 14 us is acceptable/quite normal in microseconds range.?
# define F_CPU 1843200UL
# define SCLK_ON PORTA|=(1<<PORTA0)
# define SCLK_OFF PORTA&=~(1<<PORTA0)
#define SCLK_tick _delay_us(100)
int main(){
for(;{
SCLK_OFF; SCLK_tick ;
SCLK_ON; SCLK_tick ;
}
}
For the above code i get a clock signal with period as 214 us instead of 200 us. Is it due to the fact that _delay_us() is not working properly, clock is not set properly in code, fuse settings or a deviation of 14 us is acceptable/quite normal in microseconds range.?