avr-chat
[Top][All Lists]
Advanced

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

Re: [avr-chat] AVR Test


From: Arkadiusz Krysiak
Subject: Re: [avr-chat] AVR Test
Date: Wed, 31 May 2006 00:27:54 +0200


Dnia 30-05-2006 o godz. 20:05 Dean Ferreyra napisał(a):
> Hi Chris,
> 
> I didn't want this point to get lost.  I think address@hidden was
> trying to point out one problem with the code you posted.  In this line:
> 
> >    PORTD &= !(1<<PD1); /* LED off */
> 
> you're using the logical negation operator, !, when what you really
> need is the one's complement operator, ~.  So that line should look
> like this:
> 
>   PORTD &= ~(1<<PD1); /* LED off */
> 
> With what you've written, the entire PORTD is getting zeroed out, not
> just the bit in question.
> 
> Dean
> 
> Chris Spencer wrote:
> > Nevermind, I figured it out. I didn't realize the -U flag was required
> > to make avrdude write. Now everything's working just fine.
> > 
> > Chris Spencer wrote:
> >> I was able to get my dev environment setup (thanks Galen) and
> >> successfully write a hex file to my atmega48. However, my test program
> >> doesn't make the led blink. Below is my c code and makefile. Does
> >> anyone see any glaring problems? Is my makefile setting (or not
> >> setting) the appropriate fuse bits? I'm testing on two Pololu Baby
> >> Orangutan boards (http://www.pololu.com/products/pololu/0215/), so I'm
> >> pretty confident it's not a hardware issue. All lights are green on
> >> the programmer.
> >>
> >> #include <avr/io.h>
> >>
> >> /* at 8 MHz we get 1us per 8 instructions */
> >> inline void delayus() { asm volatile("nop\nnop\nnop\nnop\n"
> >>                                        "nop\nnop\nnop\nnop"); }
> >>
> >> void delayms(uint16_t millis) {
> >>    uint16_t loop;
> >>    while ( millis ) {
> >>    loop = 100;
> >>    while (loop) {
> >>        /* 20us of delays */
> >>        delayus(); delayus(); delayus(); delayus(); delayus();
> >>        delayus(); delayus(); delayus(); delayus(); delayus();
> >>        loop--;
> >>    }
> >>    millis--;
> >>    }
> >> }
> >>
> >> int main(void) {
> >>    DDRD |= 1<<PD1; /* set PD1 to output */
> >>    while(1) {
> >>    PORTD |= 1<<PD1; /* LED on */
> >>    delayms(1000);
> >>    PORTD &= !(1<<PD1); /* LED off */
> >>    delayms(1000);
> >>    }
> >>    return 0;
> >> }
> >>
> >> CC=avr-gcc
> >> CFLAGS=-g -Os -Wall -mcall-prologues -mmcu=atmega48
> >> OBJ2HEX=avr-objcopy
> >> TARGET=blink
> >> PART=m48
> >> PROGRAMMER=avrisp2
> >>
> >> program: $(TARGET).hex
> >>    avrdude -p $(PART) -c $(PROGRAMMER) -P usb -e flash:w:$(TARGET).hex
> >>
> >> %.obj: %.o
> >>    $(CC) $(CFLAGS) $< -o $@
> >>
> >> %.hex: %.obj
> >>    $(OBJ2HEX) -R .eeprom -O ihex $< $@
> >>
> >> clean:
> >>    rm -f *.hex *.obj *.o
> >>
> >>


Thats right. I don't now why it do me. ! change only B0.  ~ change all bits in 
reg at oposite.


----------------------------------------------------
Jeszcze możesz pojechać na Mundial! Do zdobycia 68 biletów na mecze:
Polska-Ekwador, Polska-Kostaryka, Włochy-Ghana
(wejściówki, przelot i nagroda gotówkowa)
http://klik.wp.pl/?adr=http%3A%2F%2Fcms.mni.pl%2Fclient%2Fera_mundial%2Fversion%2Fwp&sid=774






reply via email to

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