Go Down

Topic: Does the IDE work? (Read 529 times) previous topic - next topic

freynox

Hi!
For the begining, I want that you now that I began to use arduino 2 month ago, and I am a noob, so I need your help!
I have dowload a library in internet, the library don't work, and I ask myself, if the IDE of arduino has change and the library doesn't work on it,because the library was create in 2011, and if yes, what can I make, so that the library work with that IDE.
thank you in advance!!

AWOL

Feel free to fill in any details you think we might need.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

sterretje

Feel free to fill in any details you think we might need.
Is your glass ball in for repairs?

@freynox
1)
a link to the library might help us to help you
2)
seeing your code might help us to help you
3)
seeing the error messages that you get might help us to help you

For 2 and 3, read the sticky how to use the forum, specifically how to post code. For 1, use the url tag.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

freynox

Here the code:
Code: [Select]
void FlexiTimer2::set(unsigned long units, double resolution, void (*f)()) {
  float prescaler = 0.0;
 
  if (units == 0)
    time_units = 1;
  else
    time_units = units;
   
  func = f;
 
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || defined (__AVR_ATmega1280__) || defined (__AVR_ATmega2560__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
  TIMSK2 &= ~(1<<TOIE2);
  TCCR2A &= ~((1<<WGM21) | (1<<WGM20));
  TCCR2B &= ~(1<<WGM22);
  ASSR &= ~(1<<AS2);
  TIMSK2 &= ~(1<<OCIE2A);
 
  if ((F_CPU >= 1000000UL) && (F_CPU <= 16000000UL)) {  // prescaler set to 64
    TCCR2B |= (1<<CS22);
    TCCR2B &= ~((1<<CS21) | (1<<CS20));
    prescaler = 64.0;
  } else if (F_CPU < 1000000UL) { // prescaler set to 8
    TCCR2B |= (1<<CS21);
    TCCR2B &= ~((1<<CS22) | (1<<CS20));
    prescaler = 8.0;
  } else { // F_CPU > 16Mhz, prescaler set to 128
    TCCR2B |= ((1<<CS22) | (1<<CS20));
    TCCR2B &= ~(1<<CS21);
    prescaler = 128.0;
  }
#elif defined (__AVR_ATmega8__)
  TIMSK &= ~(1<<TOIE2);
  TCCR2 &= ~((1<<WGM21) | (1<<WGM20));
  TIMSK &= ~(1<<OCIE2);
  ASSR &= ~(1<<AS2);
 
  if ((F_CPU >= 1000000UL) && (F_CPU <= 16000000UL)) {  // prescaler set to 64
    TCCR2 |= (1<<CS22);
    TCCR2 &= ~((1<<CS21) | (1<<CS20));
    prescaler = 64.0;
  } else if (F_CPU < 1000000UL) { // prescaler set to 8
    TCCR2 |= (1<<CS21);
    TCCR2 &= ~((1<<CS22) | (1<<CS20));
    prescaler = 8.0;
  } else { // F_CPU > 16Mhz, prescaler set to 128
    TCCR2 |= ((1<<CS22) && (1<<CS20));
    TCCR2 &= ~(1<<CS21);
    prescaler = 128.0;
  }
#elif defined (__AVR_ATmega128__)
  TIMSK &= ~(1<<TOIE2);
  TCCR2 &= ~((1<<WGM21) | (1<<WGM20));
  TIMSK &= ~(1<<OCIE2);
 
  if ((F_CPU >= 1000000UL) && (F_CPU <= 16000000UL)) {  // prescaler set to 64
    TCCR2 |= ((1<<CS21) | (1<<CS20));
    TCCR2 &= ~(1<<CS22);
    prescaler = 64.0;
  } else if (F_CPU < 1000000UL) { // prescaler set to 8
    TCCR2 |= (1<<CS21);
    TCCR2 &= ~((1<<CS22) | (1<<CS20));
    prescaler = 8.0;
  } else { // F_CPU > 16Mhz, prescaler set to 256
    TCCR2 |= (1<<CS22);
    TCCR2 &= ~((1<<CS21) | (1<<CS20));
    prescaler = 256.0;
  }
#elif defined (__AVR_ATmega32U4__)
  TCCR4B = 0;
  TCCR4A = 0;
  TCCR4C = 0;
  TCCR4D = 0;
  TCCR4E = 0;
  if (F_CPU >= 16000000L) {
    TCCR4B = (1<<CS43) | (1<<PSR4);
    prescaler = 128.0;
  } else if (F_CPU >= 8000000L) {
    TCCR4B = (1<<CS42) | (1<<CS41) | (1<<CS40) | (1<<PSR4);
    prescaler = 64.0;
  } else if (F_CPU >= 4000000L) {
    TCCR4B = (1<<CS42) | (1<<CS41) | (1<<PSR4);
    prescaler = 32.0;
  } else if (F_CPU >= 2000000L) {
    TCCR4B = (1<<CS42) | (1<<CS40) | (1<<PSR4);
    prescaler = 16.0;
  } else if (F_CPU >= 1000000L) {
    TCCR4B = (1<<CS42) | (1<<PSR4);
    prescaler = 8.0;
  } else if (F_CPU >= 500000L) {
    TCCR4B = (1<<CS41) | (1<<CS40) | (1<<PSR4);
    prescaler = 4.0;
  } else {
    TCCR4B = (1<<CS41) | (1<<PSR4);
    prescaler = 2.0;
  }
  tcnt2 = (int)((float)F_CPU * resolution / prescaler) - 1;
  OCR4C = tcnt2;
  return;
#else
#error Unsupported CPU type
#endif
 
  tcnt2 = 256 - (int)((float)F_CPU * resolution / prescaler);
}

void FlexiTimer2::start() {
  count = 0;
  overflowing = 0;
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || defined (__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
  TCNT2 = tcnt2;
  TIMSK2 |= (1<<TOIE2);
#elif defined (__AVR_ATmega128__)
  TCNT2 = tcnt2;
  TIMSK |= (1<<TOIE2);
#elif defined (__AVR_ATmega8__)
  TCNT2 = tcnt2;
  TIMSK |= (1<<TOIE2);
#elif defined (__AVR_ATmega32U4__)
  TIFR4 = (1<<TOV4);
  TCNT4 = 0;
  TIMSK4 = (1<<TOIE4);
#endif
}

void FlexiTimer2::stop() {
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || defined (__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
  TIMSK2 &= ~(1<<TOIE2);
#elif defined (__AVR_ATmega128__)
  TIMSK &= ~(1<<TOIE2);
#elif defined (__AVR_ATmega8__)
  TIMSK &= ~(1<<TOIE2);
#elif defined (__AVR_ATmega32U4__)
  TIMSK4 = 0;
#endif
}

void FlexiTimer2::_overflow() {
  count += 1;
 
  if (count >= time_units && !overflowing) {
    overflowing = 1;
    count = count - time_units; // subtract time_uints to catch missed overflows
          // set to 0 if you don't want this.
    (*func)();
    overflowing = 0;
  }
}
#if defined (__AVR_ATmega32U4__)
ISR(TIMER4_OVF_vect) {
#else
ISR(TIMER2_OVF_vect) {
#endif
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || defined (__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
  TCNT2 = FlexiTimer2::tcnt2;
#elif defined (__AVR_ATmega128__)
  TCNT2 = FlexiTimer2::tcnt2;
#elif defined (__AVR_ATmega8__)
  TCNT2 = FlexiTimer2::tcnt2;
#elif defined (__AVR_ATmega32U4__)
  // not necessary on 32u4's high speed timer4
#endif
  FlexiTimer2::_overflow();
}



and here is FlexiTimer2:
Code: [Select]
#ifndef FlexiTimer2_h
#define FlexiTimer2_h

#ifdef __AVR__
#include <avr/interrupt.h>
#else
#error FlexiTimer2 library only works on AVR architecture
#endif


namespace FlexiTimer2 {
  extern unsigned long time_units;
  extern void (*func)();
  extern volatile unsigned long count;
  extern volatile char overflowing;
  extern volatile unsigned int tcnt2;
 
  void set(unsigned long ms, void (*f)());
  void set(unsigned long units, double resolution, void (*f)());
  void start();
  void stop();
  void _overflow();
}

#endif


The error message is:
Code: [Select]
C:\Users\Edmond Schuck\Documents\Arduino\sketch_may17c\sketch_may17c.ino:28:25: fatal error: FlexiTimer2.h: No such file or directory

 #include <FlexiTimer2.h>





pert


sterretje

The first code is the cpp file. The second one is the h file.

Where is the sketch? The compiler complains about something in the sketch.

Where are the two files located? If they are in the same directory as the sketch, you need to include with double quotes instead of <>.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

freynox

I have download the library FlexiTimer2, and an another error message come :

Code: [Select]
libraries\wimleers-flexitimer2-733cfb\FlexiTimer2.cpp.o (symbol from plugin): In function 'FlexiTimer2: :set (unsigned long, double, void (*) ())`:
(.text+0x0): multiple definition of 'FlexiTimer2: :set(unsigned long, double, void (*) ())'


What does it mean?

pert

Generally it's better to post the full error output rather than just what looks relevant. When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here using code tags.

Do you have a copy of the FlexiTimer2 library in your sketch folder?

freynox

@pert I believe that you want to speak about that:
Code: [Select]
#ifndef FlexiTimer2_h
#define FlexiTimer2_h

#ifdef __AVR__
#include <avr/interrupt.h>
#else
#error FlexiTimer2 library only works on AVR architecture
#endif


namespace FlexiTimer2 {
  extern unsigned long time_units;
  extern void (*func)();
  extern volatile unsigned long count;
  extern volatile char overflowing;
  extern volatile unsigned int tcnt2;
 
  void set(unsigned long ms, void (*f)());
  void set(unsigned long units, double resolution, void (*f)());
  void start();
  void stop();
  void _overflow();
}

#endif

pert

@pert I believe that you want to speak about that:
No, I asked you a question:
Do you have a copy of the FlexiTimer2 library in your sketch folder?
The sketch folder is the folder that has the .ino file in it, C:\Users\Edmond Schuck\Documents\Arduino\sketch_may17c\ from the error you posted above.

If you have the library source files in the sketch folder and also installed normally then that could be the cause of the multiple definition error.

Go Up