avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Programming ATMega2560


From: Andreas Höschler
Subject: Re: [avr-gcc-list] Programming ATMega2560
Date: Wed, 26 Nov 2014 23:25:06 +0100

Hi Tom,

#define F_CPU 16000000UL  /* 16 MHz CPU clock */
#include <util/delay.h>
#define OUTPUTPORT PORTB
#define OUTPUTPIN PB7
int main (void)
  {
   DDRB = 0xff;          // all outputs
   while (1)                       /* loop forever */
     {
      if ((PORTB & _BV(PB7)) > 0) PORTB &= ~_BV(PB7);
      else PORTB |= _BV(PB7);
      delay_ms(500);
     }
      return (0);
  }

A couple coding problems.

You need to include avr/io.h to get port definitions.


I tried with and without. With I get 

-bash-3.2$ make
avr-gcc -mmcu=atmega2560 -Wall -O2 -I /usr/local/avr/include -I./ -o toggle_led.out main.c 
unknown MCU 'atmega2560' specified
Known MCU names:
   avr2
   at90s2313
...
   attiny15
   attiny28
main.c:1: error: MCU 'atmega2560' supported for assembler only
In file included from main.c:4:
/usr/local/avr/include/avr/io.h:530:6: warning: #warning "device type not defined"
main.c: In function 'toggleOutput':
main.c:19: error: 'PORTB' undeclared (first use in this function)
main.c:19: error: (Each undeclared identifier is reported only once
main.c:19: error: for each function it appears in.)
main.c:19: error: 'PB7' undeclared (first use in this function)
main.c: In function 'main':
main.c:34: error: 'DDRB' undeclared (first use in this function)
main.c:45: error: 'PORTB' undeclared (first use in this function)
main.c:45: error: 'PB7' undeclared (first use in this function)
make: *** [toggle_led.out] Error 1

:-(

Thanks,

 Andreas


reply via email to

[Prev in Thread] Current Thread [Next in Thread]