Re: Programming ATMega2560

Andreas Höschler <[email protected]>
Newsgroups gmane.comp.hardware.avr.gcc
Message-ID <[email protected]>
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

_______________________________________________
AVR-GCC-list mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.