Problem with inline asm + eclipse

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

Hello

I want starting to work with WinAvr+Eclipse. So far, I was successful with installing the toolchain with actual releases:

WinAVR-20080610 + avr-libc-bin-1.6-20080228
Eclipse Version: 3.4.1 (eclipse-cpp-ganymede-SR1-win32.zip)
AVR-Plugin avreclipse-2.3.0.20080915BETA1

Compiling and programming of small examples out from eclipse is working fine, the toolchain seems to be ok!

But now, I'm trying to migrate my existing projects from AvrStudio and AtmanAvr to Eclipse. But the compiler does not accept inline asm statements, it looks like he doesn’t know the keyword "asm".

Even a simple {asm ("nop");} doesn't work.

I'm almost desperate, has anybody an idea what the problem is, respectively what I might doing wrong?

Here a small sample program which doesn't compile: (I know, the "nop" make no sense, it is just to demonstrate the problem!)

#include 
#include 

#define UP  0
#define DN  1

void delay_ms(unsigned int ms)
{
  while(ms--)
  {
    asm("nop" ::);   // ==> Error
    _delay_ms(1);
  }
}

// Knight Rider's KIT - Led light
int main( void )
{
  unsigned char ledval = 1;
  unsigned char dir = UP;
  DDRD |= (0xFF);
  while (1)
  {
    PORTD = ~ledval;
    if (dir==UP)
      ledval = ledval<<1;
    else
      ledval = ledval>>1;
    if (ledval < 0x02)
      dir = UP;
    if (ledval & 0x80)
      dir = DN;
    delay_ms(150);
  }
}

=> Compile Error
../main.c: In function 'delay_ms':
../main.c:12: warning: implicit declaration of function 'asm'
../main.c:12: error: expected ')' before ':' token

Thanks in anticipation for any help or hint.

Peter

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

Have you tried the plain asm("nop");?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Yes, asm("nop") isn't working as well. the Keyword 'asm' seems to be unknown for the compiler:

../main.c:12: warning: implicit declaration of function 'asm'

Is it necessary to include something for 'asm'? Or is there something new/different with the new WinAvr. Before I was using AvrGcc 4.1.2 and WinAVR-20071221

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

I've found the problem!

By accident, I have selected the option -std=c99 instead -std=gnu99

For c99 mode, the compiler does not recognise 'asm', '__asm' ist required instead!

For gnu99 mode, both variants are accepted, 'asm' and '__asm' as well!

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

avreclipse ? plugin ?

Exactly what does this add?

I've been using Eclipse for my AVR and ARM development for well more than a year. Works like a dream, no plugins needed.

/Jesper
http://www.yampp.com
The quick black AVR jumped over the lazy PIC.
What boots up, must come down.

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

@jesper

Quote:
I've been using Eclipse for my AVR and ARM development for well more than a year. Works like a dream, no plugins needed.

If you don't know, then you should have a look at this plugin!

AVR-Eclipse is a plugin for the Eclipse IDE which adds toolchain support, through CDT, for the gcc compiler for the Atmel AVR series of microcontrollers, and adds a toolbar button to allow quick upload of produced code to a target device.

http://sourceforge.net/projects/...

Regards Peter

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

Quote:
AVR-Eclipse is a plugin for the Eclipse IDE which adds toolchain support, through CDT, for the gcc compiler for the Atmel AVR series of microcontrollers, and adds a toolbar button to allow quick upload of produced code to a target device.
Yes, that's what it say on the web-page, and that's what I've had (plus a lot more) for a long time without any plugins.
Doesn't seem worth the download.

/Jesper
http://www.yampp.com
The quick black AVR jumped over the lazy PIC.
What boots up, must come down.

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

Peter: would you mind giving up a quick summary of using Eclipse for development/debugging versus using AVR Studio that many of us use.

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

@jesper: I'm sure you can do this and much more without this pluging, if you are very familiar with the WinAvr toolchain, makefiles, batchfiles and eclipse. If not, the pluging make the live easier to start with.

Currently I'm struggling with Eclipse to get the debugger working. Unfortunately I don't know how to use avr-gdb and avrice, I have to learn and to RTFM!

But maybe you can help? Or even better, you could join to
http://sourceforge.net/projects/... and share your good knowledge + experience to improve + extend the functionalities of this plugin?

@kmr: I'm a novice with using Eclipse, but I can try to give a first impression/comparison:

AvrStudio+WinAvr is a very handy tool with a seamless integration of project+source file editor, assembler, compiler, simulator, programmer and debugger, and everything can be used for free! It is easy to use, (normally no need to struggle with makefiles etc.) and well suited for newcomer and for small C-Projects.

Some drawbacks are: AvrStudio is only available for Windows2000 and newer. There are also some pitfalls and bugs you have to live with, but this is more or less common for all softwares.

But for managing or taking over of large projects, there are various neat features of professional IDE's missing, for example code browsing functions (search for functions, declarations and definitions) object-browser, auto completion, macro expander, language specific interactive code editor etc...

On the other hand, Eclipse with the CDT-Plugin is a powerful tool to develop ant maintain large projects with all the capabilities of a professional IDE. (Including capabilities like of RCS, Mylyn etc) Currently I'm maintaining a MPC8xx project with more than 3000 Sourcfiles with sNiFF (a very old aged IDE), such a large project is barely manageable with a tool like AvrStudio. The drawback is, it is more difficult to start with a powerful and complex tool.