codeblocks+winavr开发avr单片机(atmega16)

在avrfeaks论坛里,有一个帖子是关于在codeblocks环境下(与winavr结合)开发avr单片机的,挺不错的,这里转载一下:

I got curious, so I downloaded the current C::B installer. It looks better than when I last used it (a year ago?):


- A working installation program, with no need to install graphics packages and stuff (WxWidget, MinGW) separately.
- A user manual is now available.

Upon first launch I was asked if C::B should "steal" the C and C++ filetypes. I said no at this moment.

I then was presented with a choice of copiler, and THERE IT WAS: GNU AVR GCC Compiler

So I chose that, and started creating a new project. The project type "AVR Project" was available so I chose that.

A wizard starts with the usual stuff in the first step: Project name, location etc.

Second step: Select AVR processor, and I have a ATmega88 on the STK500 so I chose that. Here is also the setting of F_CPU, what files to generate and an option to run avr-size after build.

Finish!

I now have a main.c, with a int main(void) which I add two lines to so I get:


Code:
#include 

int main(void)
{
    DDRB = 0xFF;
    PORTB = 0x55;

    while(1);

    return 0;
} 


I hit build and ... it does not work. C::B can not locate the compiler, and used odd names (In my view) for it. ON to theSettingsmenu,Compiler and Linker... item, Toolchain Executablestab. There I browse for the correct executables (in my case they are in the WinAVR installation) and add paths to the two directories containing those executables.

But there it stops: I cannot get a build to build correctly.

Choosing Compile current file I get
Quote:
Compiling: main.c
cc1.exe: error: missing argument to "-mmcu="
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

A double-check that the AVR model is set in the project confirms that it is.

Choosing Build it gets worse:
Quote:
"CBAVRtest - Debug" uses an invalid compiler. Skipping...
Nothing to be done.

Oh, well... It was woth the half-hour I spent. C::B has a nice forum with helpful people (you have to do your home/leg-work though. If you think we here at AVRfreaks are tough then you've seen nothing. Them there C::B'ers are far worse (or better?)

If anyone does anything more on this I am very interested in the results! Come back here with them!

你可能感兴趣的:(AVR/PIC)