Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: Grr, steep learning curve!!

2008-04-19 by stevech11

the constant "true" is not part of the C language. That's why you got
the error. You can:
1) code: #define true 1
2) code while(1)

note that your do/while loop does not toggle the LEDs on/off. There
are plenty of examples of how to do that, to include delay code so the
on/off rate is slow enough for you to see.

--- In AVR-Chat@yahoogroups.com, "Paul Sinclair" <paul@...> wrote:
>
>  Well, after spending hours trying to get something working I have
had to
> come crawling back.
> 
> The piece of code I have been trying to get to work is:
> 
>  
> 
> //----------------------------------------------------------------------
> 
> // Titel     : Beispiel LED an für myAVR-Board
> 
> //----------------------------------------------------------------------
> 
> // Funktion  : Schaltet alle 3 LEDs an
> 
> // Schaltung : PortB 0-2 an LEDs
> 
> //----------------------------------------------------------------------
> 
> // Prozessor : ATmega8/48/88/168
> 
> // Takt                  : 3.6864 MHz
> 
> // Sprache   : C
> 
> // Datum     : 02.12.2005
> 
> // Version   : 1.3
> 
> // Autor     : Dipl. Ing. Päd. Alexander Huwaldt
> 
> //----------------------------------------------------------------------
> 
> #define                F_CPU 3686400 // Taktfrequenz des myAVR-Boards
> 
> #include               <avr\io.h>                           // AVR
Register
> und Konstantendefinitionen
> 
> //----------------------------------------------------------------------
> 
> main ()
> 
> {
> 
>                 DDRB=0xFF;                                      
//PortB auf
> Ausgang konfigurieren
> 
>                 do
> 
>                 {
> 
>                                 PORTB=0xFF;     // PortB High, LEDs on
> 
>                 } while (true);                    // Mainloop
> 
> }
> 
> //----------------------------------------------------------------------
> 
>  
> 
> I have been using avr studio, baisically I started a new project,
and pasted
> that code in and built it. After having to make some changes, due to the
> program saying that "true not initialized" I changed the code from:
> 
>  
> 
>                 do
> 
>                 {
> 
>                                 PORTB=0xFF;     // PortB High, LEDs on
> 
>                 } while (true);                    // Mainloop
> 
>  
> 
>  
> 
>  
> 
> To
> 
>  
> 
>  
> 
>  
> 
>                 Int x;
> 
> X = 1;
> 
> While (x == 1)
> 
>                 {
> 
>                                 PORTB=0xFF;     // PortB High, LEDs on
> 
>                 }                              // Mainloop
> 
>  
> 
>  
> 
>  
> 
> It built grand then, but when I took the hex file, and used the sp12
program
> to program it, it said:
> 
>  
> 
> H:\Documents and Settings\Paul>sp12 -p -f C:/avr/test.hex
> 
> SP12 version 2.0.7 performing init...
> 
> Path to _sp12rc and _sp12dev: H:\Program Files\SP12_AVR\
> 
> Running in SP12 cable/dongle compatible mode.
> 
> Enabling AVR serial reading/programming...
> 
> The device code bytes 0,1,2: 0x1e, 0x93, 0x7 were read
> 
> from parallel port 0x378 and indicate the following:
> 
> You have connected an ATmega8
> 
> The device was made by Atmel
> 
>  
> 
> Writing 0000 (0, B00000000) to the parallel port data bits.
> 
>  
> 
>  
> 
>  
> 
> So im lost, nothing happened on the board, so I don't know if
anything has
> been programmed.
> 
> I have noticed it is very hard to find any decent tutorials aswell..
But I
> would like to be able to reliably program the device before wrecking
my head
> with code wondering why its not working.
> 
>  
> 
> It's probably time I got myself a proper development board, but I
don't have
> the money and I really just want to get started on these things,
this board
> has been sitting here for a while!
> 
>  
> 
>  
> 
> Thanks (once again)
> 
> Paul.
> 
>  
> 
> 
> 
> [Non-text portions of this message have been removed]
>

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.