Measure time in milliseconds
Hi
I am a beginner in the AVR world.
I am using Crossworks for AVR with Atmega128.
I want to measure the time execution for a function for example and print the time elapsed, I wrote this code but with 0 result:
void main(void)
{
TCCR0=(1<<WGM01) | (1<<CS01) | (1<<CS00); // start 8 bit clock/64
#asm("sei")
start = millis();
printf("start = %d", start);
for(i=0;i<100;i++)
{ y=sin(x);}
finish=millis();
printf("finish = %d", finish);
elapsed_time =finish-start;
printf("Elapsed time =");
printf("%u", elapsed_time);
}
ISR(TIMER1_COMP_vect)
{
ctl_increment_tick_from_isr();
}
unsigned long millis()
{
unsigned long m;
m = ctl_current_time;
return m;
}
I am getting 0. in the hyperterminal
Can anyone helps me.
Please sign in to leave a comment.
Comments
0 comments