Re: Programming ATMega2560

"Thomas D. Dean" <[email protected]>
Newsgroups gmane.comp.hardware.avr.gcc
Message-ID <[email protected]>
On 11/26/14 11:46, Andreas Höschler wrote:
> #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.
delay_ms(500) should be _delay_ms(500)

Tom Dean
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.