Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
To retrieve timer value://read timer0's overflow counter//255 is count before overflow, dependent on clockelapsed_time=timer0GetOverflowCount()*255+TCNT0;
On a related note, is there a way to test functions like this easily? For example is there a test application where I can output console text via the USB port or something? That would make finding out how functions like this work a lot easier.
timer0GetOverflowCount()*256 + TCNT0;
timer0GetOverflowCount()
uint16_t old = timer0GetOverflowCount()*256 + TCNT0;while(1){ uint16_t new = timer0GetOverflowCount()*256 + TCNT0; //see if the 'timer' has gone backwards! if(new<old){ int i=0;i++; // crap code but set a BREAKPOINT HERE } old = new;}
cli(); // ******* Turn off interrupts to simulate being called in an interrupt service routine **uint16_t old = timer0GetOverflowCount()*256 + TCNT0;while(1){ uint16_t new = timer0GetOverflowCount()*256 + TCNT0; //see if the 'timer' has gone backwards! if(new<old){ int i=0;i++; // crap code but set a BREAKPOINT HERE } old = new;}
int elapsed_time=timer0GetOverflowCount()*255+TCNT0; while(1) { if(((timer0GetOverflowCount()*255+TCNT0)-elapsed_time)>=16393) { rprintf("Tick!\n"); elapsed_time=timer0GetOverflowCount()*255+TCNT0; } }
timer0Init();while(1){ if( timer0GetOverflowCount()*256 + TCNT0 >= 16393){ timer0Init(); rprintf("Tick\n"); }}
long unsigned int elapsed_time=get_timer4_counter()
So, Webbot, whats the status of those timer functions? It would help a lot if I stopped getting super stupid timer information that totally throws of my PI loop every once in awhile due to those damn overflows.
Great. Let us know when you get it hosted somewhere!