Atmel AVR Microcontroller discussion group.
[AVR club] Beginner - Francois - Apr 10 8:29:56 2008
Dear Sir
I'm a new comer to programming, so I bought myself an AVR starter kit (STK500) to improve
on my programming skills. First of all, I would like to start of by playing with the
leds and switches connected to the ports. My first attempt wasn't successful(currently
using the atmega8515L chip). So could you please help me with a few programs on how to use
the leds and switches including some delay loops?
I actually would like to program in C and not in assembler. Is this a good idea?
Could you also include all the #INCLUDE and #DEFINE directives to the programs?
Thanks for your time
Francois
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
Re: [AVR club] Beginner - David Kelly - Apr 10 11:46:03 2008
On Thu, Apr 10, 2008 at 01:47:43PM +0200, Francois wrote:
>
> I'm a new comer to programming, so I bought myself an AVR starter kit
> (STK500) to improve on my programming skills. First of all, I would
> like to start of by playing with the leds and switches connected to
> the ports. My first attempt wasn't successful(currently using the
> atmega8515L chip). So could you please help me with a few programs on
> how to use the leds and switches including some delay loops?
Looking at the AVR features table at
http://dkc3.digikey.com/PDF/T081/P0574.pdf I would suggest you change to
a plain ATmega8515 rather than the L version because the not-L has JTAG
on-chip debugging. The AVR Dragon at $52 or ECROS Ice Cube will let you
reach inside the chip and see what is happening.
http://www.ecrostech.com/AtmelAvr/AvrIceCube/Stk500.htm
> I actually would like to program in C and not in assembler. Is this a
> good idea?
Yes. But don't be afraid to look at the generated assembly. If the
compiler generates nasty convoluted assembly then you probably didn't
express yourself as well as you should have.
> Could you also include all the #INCLUDE and #DEFINE directives to the
> programs?
I don't understand the question. Unix-like C compilers can provide the
results of the pre-processed source code for your review. I like to put
these lines at the end of my Makefile. "make depend" runs avr-gcc in a
special mode looking for file dependencies, and writes a Make compatible
output:
# BSD make automatically reads .depend if it exists
depend: clean $(SRCS)
$(CC) -E -M $(CFLAGS) $(SRCS) > .depend
# -include fails silently in GNU Make if .depend does not exist
# OTOH -include is not BSD Make compatible.
-include .depend
--
David Kelly N4HHE, d...@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
Re: [AVR club] Beginner - Zack Widup - Apr 10 12:05:56 2008
Hi Francois,
Isn't there an example program in the booklet for the STK500 that lets you
play with the buttons and LED's?
For little programs like that, I generally use assembler. It would be
quite easy to do with AVR Studio.
My first recommendation is to make sure you have all the jumpers and
switches on the STK500 in the right place. If you're going to program the
STK500 using the serial port connection, you'll have to arrange the
jumpers for that and then rearrange everything when you want to run the
program.
I also seem to recall the STK500 came with a chip (8515?) pre-programmed
with the little pushbutton-LED program. I believe the idea was to use
that to verify you had the jumpers and switches correct; after that you
could erase and reprogram the chip with the same program to make sure you
knew how to do that. I think what I did was try out the pre-programmed
8515 first, then erase it and re-program it with the program typed and
assembled in AVR Studio, then I tried it with a Mega8 as the next learning
step.
Good luck and I hope this helps!
Zack
On Thu, 10 Apr 2008, Francois wrote:
> Dear Sir
>
> I'm a new comer to programming, so I bought myself an AVR starter kit (STK500) to
improve on my programming skills. First of all, I would like to start of by playing with
the leds and switches connected to the ports. My first attempt wasn't
successful(currently using the atmega8515L chip). So could you please help me with a few
programs on how to use the leds and switches including some delay loops?
>
> I actually would like to program in C and not in assembler. Is this a good idea?
>
> Could you also include all the #INCLUDE and #DEFINE directives to the programs?
>
> Thanks for your time
>
> Francois
>
------------------------------------

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
Re: [AVR club] Beginner - raj - Apr 12 22:07:22 2008
=A0Dear Francois,
I have attached two programs for stk500.try and =
send some feedbck to me.If any book is available to suggest me.
best Rgds/
Kundan
On Thu, 10 Apr 2008 Francois wrote :
>Dear Sir
>
>I'm a new comer to programming, so I bought myself an AVR starter kit (STK=
500) to improve on my programming skills. First of all, I would like to s=
tart of by playing with the leds and switches connected to the ports. My f=
irst attempt wasn't successful(currently using the atmega8515L chip). So co=
uld you please help me with a few programs on how to use the leds and switc=
hes including some delay loops?
>
>I actually would like to program in C and not in assembler. Is this a goo=
d idea?
>
>Could you also include all the #INCLUDE and #DEFINE directives to the prog=
rams?
>
>Thanks for your time
>
>Francois
>[Non-text portions of this message have been removed]
>
----------
/*=0D
; Title: Getting Started with AVR=0D
; Subtitle: Ledchaser PORTA=0D
; Author: Atmel AVR Applications Group=0D
; Date: 01/2003=0D
;=0D
; Compiler: AVR-GCC=0D
; Target: All AVR's=0D
; Hardware: STK500=0D
;*/=0D
=0D
// Include definition file=0D
#include
=0D
=0D
int main( void )=0D
{=0D
unsigned char led, i, j, k;=0D
=0D
PORTA =3D 0xFF; //Give PORTA and "led" a initial startvalue=0D
led =3D 1;=0D
=0D
// DDRA =3D 0xFF; //Set PORTA as output=0D
=0D
for (;;) // Eternal loop=0D
{=0D
PORTA =3D ~led; // Invert the output since a zero means: LED on=
=0D
led <<=3D 1; // Move to next LED by performing a rotate left=
=0D
=0D
if (!led) led =3D 1; // If overflow: start with led1 again=0D
// Delay loop, approximately 160mS @ 1.23MH=
z Main Clock=0D
for (i=3D0; i<255; i++) // Outer Delay loop=0D
for(j=3D0; j<47;j++) // Inner Delay loop=0D
k++; // Just do something - could also be a NOP=
=0D
}=0D
}=0D
=0D
----------
/*=0D
; Title: Getting Started with AVR=0D
; Subtitle: Timers and Counters, PWM=0D
; Author: Atmel AVR Applications Group=0D
; Date: 01/2003=0D
;=0D
; Compiler: AVR-GCC=0D
; Target: AT90S8515=0D
; Hardware: STK500=0D
;=0D
; Description:=0D
; The application will setup the 16-bit TCNT1 to be a PWM with frequency=0D
; of 300Hz and increase the duty cycle by 1 in the compare match interrupt=
=0D
; handler is called.=0D
; By applying this signal to an LED will it increase its light intensity=0D
; until OCR wraps and then start from 0 again=0D
;*/=0D
=0D
// Include definition file(s)=0D
#include =0D
#include =0D
#include =0D
#include =0D
=0D
// Interrupt handler routines=0D
SIGNAL(SIG_OUTPUT_COMPARE1A) // Timer1A Output Compare match Handler=0D
{=0D
OCR1AL++; //Increase the duty cycle=0D
}=0D
=0D
int main( void )=0D
{=0D
DDRD =3D (1<
=0D
TIFR =3D TIFR; //Clear all TCNT interrupt flags by writing '1=
' to them=0D
TIMSK =3D (1<
OCR1AL =3D 256/2; //Set the compare match value to 256/2 to get =
50% duty cycle=0D
TCCR1A =3D (1<
, 8bit mode=0D
TCCR1B =3D (1<
ivided by 8=0D
//PWM frequency @ 1.23MHz =3D 1.23M/256/8/2=0D
TCCR1B |=3D (1<
=0D
_SEI(); // Enable global interrupts=0D
=0D
for (;;) // Eternal loop=0D
{=0D
}=0D
}=0D
=0D
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )Re: Re: [AVR club] Beginner - raj - Apr 12 22:07:48 2008
=A0Try to write program in C , It is an good idea,All the best!
On Thu, 10 Apr 2008 Zack Widup wrote :
>
>Hi Francois,
>
>Isn't there an example program in the booklet for the STK500 that lets you
>play with the buttons and LED's?
>
>For little programs like that, I generally use assembler. It would be
>quite easy to do with AVR Studio.
>
>My first recommendation is to make sure you have all the jumpers and
>switches on the STK500 in the right place. If you're going to program the
>STK500 using the serial port connection, you'll have to arrange the
>jumpers for that and then rearrange everything when you want to run the
>program.
>
>I also seem to recall the STK500 came with a chip (8515?) pre-programmed
>with the little pushbutton-LED program. I believe the idea was to use
>that to verify you had the jumpers and switches correct; after that you
>could erase and reprogram the chip with the same program to make sure you
>knew how to do that. I think what I did was try out the pre-programmed
>8515 first, then erase it and re-program it with the program typed and
>assembled in AVR Studio, then I tried it with a Mega8 as the next learning
>step.
>
>Good luck and I hope this helps!
>
>Zack
>On Thu, 10 Apr 2008, Francois wrote:
>
> > Dear Sir
> >
> >
> >
> > I'm a new comer to programming, so I bought myself an AVR starter kit (=
STK500) to improve on my programming skills. First of all, I would like t=
o start of by playing with the leds and switches connected to the ports. M=
y first attempt wasn't successful(currently using the atmega8515L chip). So=
could you please help me with a few programs on how to use the leds and sw=
itches including some delay loops?
> >
> >
> >
> > I actually would like to program in C and not in assembler. Is this a =
good idea?
> >
> > Could you also include all the #INCLUDE and #DEFINE directives to the p=
rograms?
> >
> >
> >
> > Thanks for your time
> >
> > Francois
> >
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )