[Top][All Lists]

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

Re: [avr-gcc-list] light up and led

From: Timothy Smith
Subject: Re: [avr-gcc-list] light up and led
Date: Thu, 06 Oct 2005 19:54:38 +1000
User-agent: Mozilla Thunderbird 1.0.7 (X11/20051002)

Joerg Wunsch wrote:

Timothy Smith <address@hidden> wrote:

   while (1) {
       PORTA &= !(1<<PA0);

! is the Boolean negation.  You want bitwise negation, operator ~.

ok i made it turn on. now i've attempted to make it blink, unsuccessfully. the light just stays off now. also, is there a more elegant way of doing time delays? i've seen many examples, most of wish look rather rough for such a simple requirment

#include <avr/io.h>

void wait (void)
   asm volatile ("nop"::);

   unsigned char j;
   unsigned char i;
   DDRA |= 1<<PA0;
   while (1) {
       for (i=0; i<20000; i++) wait();
       PORTA |= 1<<PA0;
       for (j=0; j<20000; j++) wait();
       PORTA &= ~(1<<PA0);

reply via email to

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