help pleaseeeee! XMEGA time capture or time.h file

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

does the avr xmega 128a1 xplain supports time.h ? does anyone know where can I get the correct time.h file for avr ? is it the right one?

https://github.com/vancegroup-mi...

I need to capture time at a specific point, say t0 and another time when the processing stops, say t1. Then get its difference , t1-t0 and printf it on the lcd. does anyone has an 'avr way' of doing it? I am using studio 4. After doing some googling I found out that there is no actual time.h support for avr. Is it so?

pseudo code if using time.h

#include 

int main(){
	clock_t t1, t2;
	bool gate = true;
	while(){
		if(!sinewave()){
			if(gate == true){
				t1 =clock();
				gate = false;
			}
			send();
		} else {
			stop();
			t2 = clock();
			float diff = (((float)t2 - (float)t1) / 1000000.0F ) * 1000;   
		}
	}
}

please help, thanks guys! I have a deadline for my project demo, that is next tuesday :(

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In order to have time-anything you need a timekeeper to start with. Do you have a battery backed RTC chip on your board?
If so the rest is easy, well easier.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

time.h and the accompanying functions are at HEAD in AVR-LibC. If you use avr-gcc/AVR-LibC you can either pull the files from SVN and build them locally or wait for the next issue of the compiler/lib.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

time.h and the accompanying functions are at HEAD in AVR-LibC. If you use avr-gcc/AVR-LibC you can either pull the files from SVN and build them locally or wait for the next issue of the compiler/lib.

 

Sorry, I don't understand all the shorthand. What's SVN? Could you expand on the details of what's required to get a working time.h for the GCC toolset?  I too have a project using an on-board RTC (PCF8563 in my case) and would prefer to write my drivers for that chip to be compatible with standard C functions as far as possible. Thanks.

Electronic components work on the principle of smoke; I know this because when I let the smoke out, they stop working. Also, sanity is over-rated.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

SVN is the code versioning system used for avr-LibC.

 

You can see an online view of what's held there here:

 

http://svn.savannah.nongnu.org/v...

 

The new stuff to support <time.h> is under the time directory you see there. You also need the actual .h file to accompany this. It's at the bottom of this list:

 

http://svn.savannah.nongnu.org/v...

 

#include that .h file and add any of the .c/.S files from the libc/time directory to your project that support the functions you want to call.

 

Pretty soon I'm sure there'll be an issue of the compiler, binutils and libc that include all this stuff.