include file problem

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

I'm trying to write a code using some C function (as I only have "C programming language" knowledge)like clock_t().But when I try to include library function time.h in the code it cause error as no such file in the directory.
Then I find out that avr studio library file arrangement is a little bit different.And also I find two time.h file from this two directory
-->WinAVR-20100110/win32/include
-->WinAVR-20100110/win32/include/machine
when I copy time.h from first directory to the include file directory of avr it find the include but show some error.but when I copy that form second one it show no error or warning.

:shock:

My questions are :?: :?:

    1.Is this kind of header files contains same functions like c?? 2.Is there any way I can use C's header files?
    3.Is there any sources where I can find out what are the functions and its applications of all header files of AVR studio 4 ???
thanks in advance for advices and answer and apology if I talk too much to ask this questions (As I think I do ) 8)

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

You don't want to be moving system files around. They should be included like this:
#include

Quote:
1.Is this kind of header files contains same functions like c??
It is a header file like any other header file. As such, it should not include functions, only function prototypes.
Quote:
2.Is there any way I can use C's header files?
As I showed above, use <> instead of "". However, the utility of time.h will be limited since it is meant for use in a system that has an OS (that presumably has access to a real time clock).
Quote:
3.Is there any sources where I can find out what are the functions and its applications of all header files of AVR studio 4 ???
The avr-libc manual would be a good place to start.

Regards,
Steve A.

The Board helps those that help themselves.

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

There is no time.h for AVR included in any released version of avr-libc (AFAIK). But there is one in the svn version.

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

Koshchi;
I think you didn't get my first two question right.

Quote:
1.Is this kind of header files contains same functions like c??

here by function, I mean function prototypes.but the question is a function calling like difftime() will work same in avr as it in C??
Quote:
2.Is there any way I can use C's header files?

I tried with <> also.same problem.
C's header files were kept in different directory,what I wanna ask if I somehow include them(giving the total path of the header file or copy-pest it as I mention before), do they work perfectly for my MCU code???

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

There is probably a time.h for a Pentium c compiler on your computer, but you want the time.a library with the avr .o object files for difftime all libraried up and ready to link with the atmelstudio compiler. I'd just google for the c source to difftime.c and add it to the project. You'll have to make a timer interrupt that increments a 32 bit time and puts it in a time_t struct. This sort of stuff should probably eventually find its way down into the 8 bit compiler and library, because they do have timers and deal with file systems on sd cards with dates on them. etc.

Imagecraft compiler user

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

If you mean can you use library functions from a PC implementation of the C library, No. You need to use an AVR specific library that is specific to your C compiler. If you are using WinAVR (AVR-GCC) you need to use the functions in avr-libc supplied with the compiler. You were directed to the documentation for it in a previous post.

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

Anklon,

AVR-GCC is built as a 'freestanding' compiler (per ISO/IEC 9899, section 4.6 ).
Standing by itself, many of the standard C libraries are missing.

AVR-Libc provides most of those missing libraries, however the current release does not include the time library.
will be included in the next release.

You can obtain the most recent development version of AVR-Libc via SVN or CVS from
http://savannah.nongnu.org/projects/avr-libc/

Or, you an obtain just the time package from
https://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_type=project&item_id=3772
I updated it from the SVN head this morning. Type "make help" to get started.

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

If i use timer interrupt,
is there any way I can restart that timer when i want??
I mean, suppose timer interrupt give an interrupt and it will give me next interrupt after 10 second,
but after 5 second I get some responce from any device and need to restart the timer counting so it will give next interrupt after 10 second from now. How can I do this ???

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

Stop the timer (i.e. manupulate the prescaler so that the timer does not run) Clean up any interrupts thar are pending. Then just write 0 to the T/C register, and restart the timer.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Quote:
and restart the timer.

you mean to reset the prescaler again???

Quote:
Clean up any interrupts thar are pending. Then just write 0 to the T/C register

can not understand properly.:/
can you explain in detail ??

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

There is no reason why you can't use the regular functions. Simply port them from Linux or PC.

You will need to implement the low-level timing functions. e.g. with a 10ms timer interrupt or RTC chip.

Bear in mind that most embedded apps don't have a RTC and don't have the internet and probably want to run off a battery and sleep most of the time.

Hence, no supplied with avr-gcc.

David.

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

Quote:

you mean to reset the prescaler again???

What does the datasheet say in the "prescaler" (Clock Select) table? Something about a certain value indicating "No clock source (Timer/Counter stopped)."?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Quote:

Hence, no supplied with avr-gcc.

Yet! See:

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

So next time someone labels and takes a copy of AVR-LibC HEAD it will have and associated libc support.

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

Quote:
Yet! See:

http://svn.savannah.nongnu.org/v... ... t=avr-libc

So next time someone labels and takes a copy of AVR-LibC HEAD it will have and associated libc support.

Thank you for the heads-up on this, Cliff!

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Quote:
Yet! See:

I wish I said that...

Oh. I did ;-)