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.

ATMEGA32 Sample progrms

Status
Not open for further replies.

villuribhanu

Junior Member level 1
Joined
Oct 9, 2007
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
hyderabad
Activity points
1,393
atmega32 example

Hi to all,
Myself is Bhanu. I am having command on Assembly language for ATMEGA series. Now I want to write the code in C language for ATMEGA series.Can any one one help me in this aspect.
 

xxtigerxx

Advanced Member level 1
Joined
Jun 5, 2001
Messages
444
Helped
38
Reputation
76
Reaction score
32
Trophy points
1,308
Location
Greece
Activity points
2,903
atmega delay

Could you be more specific.

i want compiler to you want to write and what?

:p
 

crowinu

Member level 2
Joined
Apr 1, 2005
Messages
48
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,621
atmega32 adc code

villuribhanu said:
Hi to all,
Myself is Bhanu. I am having command on Assembly language for ATMEGA series. Now I want to write the code in C language for ATMEGA series.Can any one one help me in this aspect.


what exactly do you want, you have code in assembly and need to convert it?
 

villuribhanu

Junior Member level 1
Joined
Oct 9, 2007
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
hyderabad
Activity points
1,393
atmega32 sample code

Hi,
Thanks all for responding to my quiery. Now I am trying to write my code in C language using the AVR Studio 4. I need some guide lines or sample programs in C which can be compiled by AVR STUDIO 4. Need sample programs like

1. UART Tx,Rx with and without interrupt
2. LCD 4 lines Data
3.SPI to EEPROM( The EEPROM u can suggest me)
4.ADC
5.PWM
6.SPI to Flash Memory

If u have more than this also u can forward to me.

With Regards,
Bhanu
 

crowinu

Member level 2
Joined
Apr 1, 2005
Messages
48
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,621
atmega32 uart

villuribhanu said:
Hi,
Thanks all for responding to my quiery. Now I am trying to write my code in C language using the AVR Studio 4. I need some guide lines or sample programs in C which can be compiled by AVR STUDIO 4. Need sample programs like

1. UART Tx,Rx with and without interrupt
2. LCD 4 lines Data
3.SPI to EEPROM( The EEPROM u can suggest me)
4.ADC
5.PWM
6.SPI to Flash Memory

If u have more than this also u can forward to me.

With Regards,
Bhanu

regarding uart etc did you had a look at atmega32 datasheet Bhanu ? there is many use full information in it even some sample codes.
 

villuribhanu

Junior Member level 1
Joined
Oct 9, 2007
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
hyderabad
Activity points
1,393
atmega32 code

Hi,
I gone through the datasheet. I wrote a code(UART) also.
But it was not working in Proteus. I am getting garbage values.
 

crowinu

Member level 2
Joined
Apr 1, 2005
Messages
48
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,621
atmega32 uart example

villuribhanu said:
Hi,
I gone through the datasheet. I wrote a code(UART) also.
But it was not working in Proteus. I am getting garbage values.

can you post the code? and the dsn of proteus.

and y don't u try it in real life instead of simulating ?
 

villuribhanu

Junior Member level 1
Joined
Oct 9, 2007
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
hyderabad
Activity points
1,393
atmega32 uart code

Hi,
This is my code. After getting output from proteus I want to make a board.
Proteus(DSN) was not attaching to this.If you dont mind can you give ur
mail ID so that i can forward it to you.

#include<avr/io.h>
void uart_init();
void delay();
unsigned char USART_Rx();

int main()
{
unsigned char data;

uart_init();

for(data='a';data<='z';data++)
{

while(!(UCSRA & 0X20));
UDR=data;
delay();
}

return 0;
}

void uart_init()
{
UBRRH=0;
UBRRL=52;
UCSRB=0X18;
UCSRC=0X86;

}

unsigned char USART_Rx()
{
while ( !(UCSRA & (1<<RXC)) );
return UDR;
}

void delay()
{
unsigned int i,j;
for (i=0;i<100 ;i++ )
for(j=0;j<30;j++);
}
 

senthilkumar

Advanced Member level 1
Joined
Nov 24, 2001
Messages
401
Helped
27
Reputation
54
Reaction score
19
Trophy points
1,298
Location
india
Activity points
3,969
uart atmega32

Hai,
Use ICC Compiler,it has the 30 days Eval full version,which has built in code generator
 

firmware

Member level 4
Joined
Apr 10, 2007
Messages
69
Helped
4
Reputation
8
Reaction score
1
Trophy points
1,288
Activity points
1,599
atmega example

Some compiler provide you a code generation such as CodeVision C compiler try to use it.
 

segmex

Advanced Member level 4
Joined
Oct 25, 2006
Messages
114
Helped
7
Reputation
14
Reaction score
6
Trophy points
1,298
Activity points
1,828
atmega32 codes

bascom is good

if anyone needs code and proteus files i can provide it .
 

villuribhanu

Junior Member level 1
Joined
Oct 9, 2007
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
hyderabad
Activity points
1,393
atmega examples

Hi,
Thanks for you. But I need a source code which work in AVRStudio 4.If it so plz forward to me.
 

firmware

Member level 4
Joined
Apr 10, 2007
Messages
69
Helped
4
Reputation
8
Reaction score
1
Trophy points
1,288
Activity points
1,599
atmega32 samples

Visit on avrfreaks.net many AVR user in side.
 

crowinu

Member level 2
Joined
Apr 1, 2005
Messages
48
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,621
sample atmega programs

villuribhanu what frequency are you using (Fosc) ?
 

crowinu

Member level 2
Joined
Apr 1, 2005
Messages
48
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,621
atmega32 sample

villuribhanu said:
I am using Internal 1Mhz.

your UBRR register is set incorrectly. check on the datasheet of the atmega32 pg165, i also tried to simulate it on proeus it worked fine.

in that table found in page 165 you have the UBRR value for certain baudrates @ Fosc 1Mhz.
 

villuribhanu

Junior Member level 1
Joined
Oct 9, 2007
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
hyderabad
Activity points
1,393
atmega32 sample programs

Hi,
Thanks for your response.
I changed my UBRR to 0x0c also
Still it is not working. If you dont maine
can you send the working code.

Hope a response for this mail.
 

crowinu

Member level 2
Joined
Apr 1, 2005
Messages
48
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,621
atmega32 example code

villuribhanu said:
Hi,
Thanks for your response.
I changed my UBRR to 0x0c also
Still it is not working. If you dont maine
can you send the working code.

Hope a response for this mail.


now in the simulation (ISIS) set the atmega clock frequency to 1Mhz and set the virtual terminal baudrate to 4800 this should work.
 

villuribhanu

Junior Member level 1
Joined
Oct 9, 2007
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
hyderabad
Activity points
1,393
atmega assembly

Hi,
I am using 9600 as baud rate.
But u mentioned that 4800. Can
u give me the clarity for this.
 

is_razi

Full Member level 3
Joined
Apr 6, 2002
Messages
159
Helped
13
Reputation
26
Reaction score
7
Trophy points
1,298
Location
Tabriz
Activity points
1,160
uart in atmega32

villuribhanu said:
Hi to all,
Myself is Bhanu. I am having command on Assembly language for ATMEGA series. Now I want to write the code in C language for ATMEGA series.Can any one one help me in this aspect.

here is a forum specially for avr micros, you can find bunch of full projects for avr in c or assembly.
www.avrfreaks.net
good luck.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top