Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Let's learn & build simple AVR project!Need ur participa

Status
Not open for further replies.
i think we must learn a basic first about learning in avr. How about build an easy development board first so we can emulate the programming in hardware, or we can make an programming first for the ic so the ic can working. I think i have a simple project about building an simple project like blinking 1 led.Do you want the blinking led project?
 

i think is good to
basic
why we not make from the example
so we can knew theprogram
 

Re: Let's learn & build simple AVR project!Need ur parti

I agree with you thomgun!!, a blinking led project is a good think to start, then we can continue with ADC, Keyboard, LCD, Serial Comm...., etc.
 

Re: Let's learn & build simple AVR project!Need ur parti

For those who didnt chose the compiler, check this
 

Ok, Mr Moof. I have decided to use a codevisionavr because it can programming in c language and this language are familiar. And there is many application using c language. So,we must decided what IC should we use, i recommed to use AVRMega8535.because this IC have many useful function like a ADC. How about you mr moof? what ur suggestion about chip should we use to build this project?
 

Mr. Moof i have a simple code to build a running led project. It will make a led run from PORTB.0 to PORTB.7 and back again. I got it from Mr.GeorgeM.Thx Mr.George!!
//running led program using codevisionavr
#include <mega8535.h>
//initialization
image=0x01;
portb=image;
//initialize delay procedure
void delay(void) //i add this command, but i'm not sure right or wrong

void main ()
{while(1)
{
while(image!=0x80)
{
image=image<<1;
portb=image;
delay();
}
while(image!=0x01)
{
image=image>>1;
portb=image;
delay();
}
}
}
void delay ()
{
}
but Mr. Moof there is no delay procedure can you add the delay procedure?Maybe we can build a 1 second delay?
 

Re: Let's learn & build simple AVR project!Need ur parti

have you looked what codevision help say about delay...?

codevision have build in delay function.

#include <delay.h>
.
.
.
while(1)
{
delay_us(100); //100 micro second delay
//do something;
delay_ms(10); // and 10 ms delay
//do something else;

)

or make some loops in your own delay function...
void delay ()
{
i=1000;
while(i)
{
i=i-1;
}
}
 

Re: Let's learn & build simple AVR project!Need ur parti

HI ... KIDS ...
Jus dropping by . Why don't you start with a REAL TIME CLOCK project
and a SERIAL interface ..so you can set the TIME with a TERMINAL connection like HYPERTERMINAL or other .. and send the time trough the SERIAL connection every minute or so !

THE BENEFITS of this project is that you will learn how to program a TIMER unit and to deal with INTERRUPTS, also how to comunicate through a UART .. both things use INTERRUTS ..
 

Thx Mr eltonjohn. ur idea is very great. but i'm still studying in learning programming in embedded system. So, do you have any simple project?we are a newbie an avr project.
 

Does any one have example source code in c programming to program AVR ic?So, we can analyze the program together.
 

Is any book for AVR chips like are for PIC chips?
 

I started with PIC 1 year ago.

Do I really need to learn AVR to survive in the world?

What I am gaining with PIC and what I am loosing by choosing AVR or something else?

A bandchmark of the market would be useful.

thank you
 

Re: Let's learn & build simple AVR project!Need ur parti

Hello every body...

I've got some comments about all of this :

1. I think it's a good idea for you to learn together... nice idea :)

2. What ever project you should do, Remeber that you need to learn something, but every learn at defferent speed... some make it step by step and you shouldn't try to do a robot first (wheel management, sensor management, state machine, Uart if you want, few timers, Analog...) you should learn step by step

3. To answer to Zanov : no you don't have to learn AVR, but it's a good 8 bit micro... the core is quiet new compared to PIC... so you should have a look at this (at least)

4. I have seen that you are agree about the language (C) but not on the compiler... What I suggest you is to use a free one based on GCC (GNU).. for several reason..
> it's free
> it could be interfaced with AVR Studio
> it uses C
> the site : https://www.avrfreaks.net give a lot of support

5. I would be glad to help you to do such a work... I know C language and Winavr and of course AVR micro...

Manitooo
 

Re: Let's learn & build simple AVR project!Need ur parti

thomgun_lc said:
Does any one have example source code in c programming to program AVR ic?So, we can analyze the program together.

Check out this AVR Microcontroller Course:
https://instruct1.cit.cornell.edu/courses/ee476/

They use AVR with CodevisionAVR compiler.

This is a good site for AVR beginners, there is also a lot of suggestions for projectes.


I use CodevisionAVR myself, it is a good AVR compiler and very easy to use, also for beginners in microcontrollers and/or C.


I thik it would be better to use the forum at avrfreaks for this projects instead of the Microcontroller forum here at EDAboard.
The forum at avrfreaks is similar to this forum, but it is only about AVRs and you will find many more avrfreaks members interested in the same idea the EDAboard members. Many EDAboard members wich are interested in AVR MCUs are also a member at AVRfreaks, but AVRfreaks also have a lot of members who are not a member here and they are all interested in AVRs.
So I suggest you start this topic at AVRfreak's forum instead, then you will get more replies:
www.avrfreaks.net/phpBB2


Moof said:
For those who didnt chose the compiler, check this
This topic is useless, it's about compilers for ARM MCUs and not AVR MCUs!
But you can search this forum and find similar topics for AVR.
Codevision is a good choiche in my opinion, cheap, stable and very easy to use.
If you want a free compiler, check out the GNU C compiler at: www.avrfreaks.net/AVRGCC

Here is a good article about which C compiler to choose:

Which C-compiler should I choose?
Unofficial comparison of available C-compilers for the AVR
Adam Johnson, march 2002
www.avrfreaks.net/Freaks/Articles/AdamJohnson/intro.php
 

Re: Let's learn & build simple AVR project!Need ur parti

I don't do AVR, but I picked up PICs about a year ago. But as a beginner, pin I/O, interrupts, timers, uart are essentials. Master these before you proceed. And trust me, these are really the basics. If you find these complicated, then you can jolly well give up the hobby.

Note : Mastering the UART is an extremely important task. It serves as a debugging feedback channel. Great for catching irritable bugs.
 

hi every one, thx for your opinion, so what should i do first. i have analyzed about bouncing led from port a.0 to port a.7. does anybody have a simple source code so we can analyze the program, such as making combination from three colour led (green, blue, red) then we use a PWM and of course write a program using C language and use avr at90s2313. Does anyone want to help us? by learning simple seperate program we can learn and analyze.
 

my code:
include "m32def.inc"
.def mpr=r16
ldi mpr,0xff
out ddrb,mpr

read:
ldi zh,high(mytable<<1)
ldi zl,low(mytable<<1)
;adiw zl,4
;lpm
;MOV R24,R0 ; Copy LSB to 16-bit register
ADIW ZL,4 ; Point to MSB in program memory
LPM ; Read MSB of table value
MOV R25,R0 ; Copy MSB to 16-bit register
out portb,r25
rjmp read
mytable:
.dw 0XCF;0
.dw 0X03;1
.dw 0X5D;2
.dw 0X5B;3
.dw 0X93;4
.dw 0XDA;5
.dw 0XDE;6
.dw 0X43;7
.dw 0XDF;8
.dw 0XDB;9



a=6
b=0
c=1
d=3
e=2
f=7
g=4
dp=5
 

Re: Let's learn & build simple AVR project!Need ur parti

2ed:
Code:
#include "iom32.h"
const unsigned char num[10]={0X3F,0X24,0X5D,0X75,0X66,0X73,0X7B,0X25,0X7F,0X77};
char i=0;
void delay(unsigned long int delayValue)
{
unsigned long int a;
for(a=0;a<delayValue;a++) ;
}


main()
{
  DDRB=0xff;//PORTB as output
  for(;;)
    {
      if(i<=9)//分别显示0-9
        {
          PORTB=num[i];
          delay(662767);
          i++;
         }
      else
        {
          i=0;
         }
     }

}
 

Re: Let's learn & build simple AVR project!Need ur parti

3rd:
Code:
.include "m32def.inc"
.def mp=r16;
.def tm=r17;timer 1
.def tm2=r18;timer2
.def tm3=r21;timer3
.def shu=r19;loop counter
.def max=r20;max of loop
;.def num=r21
;----ldi number---
ldi tm3,250
ldi max,23
;ldi num,2
;----dingyi0----
ldi mp,0xff
out ddrb,mp
out ddrd,mp
out ddrc,mp;aaa
out portc,mp;aaa
;======stack=======
ldi mp,high(ramend)
out sph,mp
ldi mp,low(ramend)
out spl,mp
;=================
ldi mp,0x80;aaa
out mcucsr,mp;aaa
main:

	ldi mp,0X3F;0显示first0
	out portb,mp
	ldi mp,0xfe
	out portd,mp
	nop
	;clz
	rcall delay1

	ldi mp,0X24;1display 1
	out portb,mp
	ldi mp,0xfd
	out portd,mp
	nop
	;clz
	rcall delay1

	ldi mp,0X5D;2display 2
	out portb,mp
	ldi mp,0xfb
	out portd,mp
	nop
	;clz
	rcall delay1

	ldi mp,0X75;3display 3
	out portb,mp
	ldi mp,0xf7
	out portd,mp
	nop
	;clz
	rcall delay1

	ldi mp,0X66;4display 4
	out portb,mp
	ldi mp,0xef
	out portd,mp
	nop
	;clz
	rcall delay1

	ldi mp,0X73;5display 5
	out portb,mp
	ldi mp,0xdf
	out portd,mp
	nop
	;clz
	rcall delay1

	ldi mp,0X7B;65display
	out portb,mp
	ldi mp,0xbf
	out portd,mp
	nop
	;clz
	rcall delay1

	ldi mp,0X25;7display
	out portb,mp
	ldi mp,0x7f
	out portd,mp
	nop
	;clz
	rcall delay1



	rjmp main








delay1:;delay 1ms
	inc tm
	breq jmm1
	rjmp delay1
	jmm1:
		clz
ret
 

Re: Let's learn & build simple AVR project!Need ur parti

4th:
Code:
.include "m32def.inc"
.def mp=r16
.def tm=r17
.def tm2=r18
.def shu=r19
.def max=r20
.def tm3=r21
ldi tm3,250
ldi max,23
ldi mp,0xff
out ddrb,mp
ldi mp,high(ramend)
out sph,mp
ldi mp,low(ramend)
out spl,mp
main:
	ldi zh,high(mytable<<1)
	ldi zl,low(mytable<<1)
	ldi shu,0
	loop:
		cpse shu,max
		rjmp dis
		rjmp main
		dis:
			;add zl,shu
			lpm
			mov mp,r0
			out portb,mp
			rcall delay10
			inc shu
			adiw zl,2
			rjmp loop





Delay10:
	inc tm
	brne delay10
	inc tm2
	brne delay10
	inc tm3
	breq jmm
	rjmp delay10
	jmm:
		clz
		ldi tm3,250
RET

;.eseg
mytable:
.dw 0XCF;0
.dw 0X03;1
.dw 0X5D;2
.dw 0X5B;3
.dw 0X93;4
.dw 0XDA;5
.dw 0XDE;6
.dw 0X43;7
.dw 0XDF;8
.dw 0XDB;9
.dw 0XD7;A
.dw 0X9E;b
.dw 0XCC;C
.dw 0X1C;c
.dw 0X1F;d
.dw 0XDC;E
.dw 0XD4;F
.dw 0X97;H
.dw 0X96;h
.dw 0X8C;L
.dw 0XD5;P
.dw 0X9C;t
.dw 0X10;-
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top