Google
Showing posts with label AVR. Show all posts
Showing posts with label AVR. Show all posts

Oct 15, 2009

Dely loop in AVR

Amer:

Hello freinds.
Can anybody help me regarding how to write a assembly language delay loop (loop-in-loop method no use of internal timers) for AVR microcontroller and how to evaluate the time delay provided by a loop?
I have an example of such loop taken from EFY mag's Nov.05 issue. You can help me by explaining the calculations for that code. The code goes as follows:-


delay: clr r19
ldi r17,$ff
loop1: inc r17
brne loop1
inc r19
brne loop1
ret
Please include the step by step calculation procedure for the delay loop in your reply so that i will be able to write loops for desired delay.
Also does anybody has another type of such code to generate delay? please explain the evaluation of the same.
Thanks in advance...

Arun Dayal
May be my C code for PWM Servo controller routine help u! Just follow my web at http://www.dayalsoft.com . An ASM delay can be written similarly. The routine is not using any of the internal timers and produces a variable delay ranging from 800 to 1250 uS precisely.

sajiD
main:
ser r16
loop1:
dec r16
brnq loop1
ret
that is very ez ok

Prasanna.S

for calulation of delay loop you should know the clock cycle period(i.e1/frequency) once you get this if you are writing code in assembly language you have to check no. of cyles required for each instruction(but for avr most of the instruction are single cycle)
refer processor manual write a simlpe code with decrement in loops the value to be given is calculated
no to be decremented=sec required/(no of cycles /loop)*period in sec

to exact value you have to consider the jump instruction in the end of loop completion etc.

Oct 13, 2009

C Programming Options in AVR

I am new to AVRs
I want to know what all programming options are there for C.
I know about BASCOM, but dont personally like BASIC that much.

ans:

* hey try codvisionavr c compiler .....it good and easy to learn and when u become pro use
WinAVR GCC

* I think you should see the page http://www.lancos.com and everthing will be clear! U will be able to make ur own circuit to program downloader circuit! as well as software to download for free!
U should use IAR Embedded C Compiler! It is widely supported by C Libraries and Evaluation version if free and sufficient for new users!

One of the International Journal Paper of mine for Your Use
http://www.convergencepromotions.com/atmelonline/v_9/pdf/AtmelJournal_V9_ConstructingA16-Channel.pdf

Similar ones u could find at http://www.atmel.com web site

* You may try AVRstudio from http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2725 along with WINAVR from winavr.sourceforge.net/ . AVRstudio serves as the IDE and Debugger/Simulator and WINAVR the C compiler. Both complement each other.

For the hardware part you could try the JTAG emulator described in this site.
http://www.scienceprog.com/build-your-own-avr-jtagice-clone/

I have made the emulator using GP board and it works perfectly.

* i recommend you to use C Language for programming AVR microcontroller
C is quite commonly used for programming microcontrollers and a lot of help is
available on programming microcontroller in C
you can design your own programmer for AVR because AVR microcontroller has SPI & other ports for In-Circuit programming

Sep 17, 2008

Driving a Stepper Motor with an AVR Microprocessor

Here are step by step DIY ( do it yourself ) instructions on how to drive a Stepper Motor with an AVR Microprocessor. If you are not sure about which type of stepper motor you have, the following links might be helpful for you in getting better insight on the stepper motor.

Stepper Motor types

Other stepper motors

Overview of the DIY for Driving a Stepper Motor with an AVR Microprocessor : Starting up with the DIY , all you need is ohmeter, followed by some simple driver code on your microprocessor.


Based on the type of the stepper motor you have to figure out the common ground and then the stepping order. Then is motor is tested with initial code. Once we have the testing done the motor driver is to be added with the code burned then the stepper motor is ready to be controlled.


Source

You might be also interested in:

:: Program to display ASCII characters on the display unit
:: 8051 based project for electrical students
:: free and open source 8086 Microprocessor Emulator

Jul 14, 2008

8051, FREESCALE, PIC, AVR. which is better ?

I am presently working on developing applications using 8051 and freescale 8 bit microcontrollers.

I wanted to know. in what terms terms the 8-bit series of microncontrollers namely. 8051, PIC, FREESCALE, AVR. are better from each other and why?

Actually now I have to learn PIC for the rest of the projects that i have two accomplish.


rishi says:
8051 ---- for learning n getting started in embedded systems

PIC ---- reach peripheral set and tremendous resources at every level

AVR ---- user friendly mainly for hobbyist

freescale ---- used in industry.

see PIC,AVR, FREESCALE all are used equally.the difference lies just in the application where they are used.

8051 is not used in industry.its modern derivative are used where they r almost equivalent 2 pic n avr in features like u can check high performance 8051 from silicon labs.i use them n they r monsters really.

anudeep says :
it isnt like that. many products till this date use 8051
example
(1)the coin box phones use atmel's 8052 at89c52 series. at least the 1se used
in india
(2)many mp3 players use 8051. where quality isnt an issue ie fr industrial purposes.if u want quality go fr vs2001(arm7 core)
(3)8051 is still used in card readers(sd,mmc and stuff----yes....there are ranges
from atmel)
(4)8051 is used fr protocol convectors ie usb to serial convectors,etc.
so it depends on the application frankly.

pic,avr,arm are equally important. cause at the end of the day.when you design a product the 2 most important things in your mind should be cost and quality.
so we have to choose the controllers accordingly.


You might be also interested in:

:: Assembly Language Programs on strings
:: Assembly Language Programs to compute an expression
:: Interfacing Analog-to-Digital converter to 8086 using 8255

Jul 6, 2008

AVR Interrupt in C

AVR programming in C interrupts

hey...most of you guys must have tried AVR interrupts in C.. I am trying to use UART receiver interrupt. I am using WinAVR.. I am including my code below, it looks it is branching to RESET.

the program is done by: niyaz zubair



int main(void)

{

unsigned char t1,t2;

long int i;

//configuring all ports



DDRA = 0xFF;

DDRB = 0xFF;

DDRC = 0xFF;

DDRD = 0xEF;



//for (i=0;i<10;i++)

// delay(4000);

lcdinitroutine();

cmdroutine(0x80);

dataroutine('s');

USART_Init(0x17);

USART_Transmit('A');

cmdroutine(0xC8);

dataroutine('Q');

while(1)

{

;

}

}



void USART_Init( unsigned char baud )

{

/* Set baud rate */

/* Enable receiver and transmitter, Rx complete
interrupt*/

UCSRB = (1<<RXEN)|(1<<TXEN)|(1<<RXCIE);

/* Set frame format: 8data, 2stop bit,Even parity */

UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0)|(2<<UPM0);

/* Configuring for 1200 bps baus*/

UBRRH = 0;

UBRRL = 50;

/* Global Interrupt
Enable*/

SREG = SREG | (0x80);

}



void USART_Transmit( unsigned char data )

{



unsigned char letter;

letter ='A';

while(letter != 'Z')

{

/* Wait for empty transmit buffer */

while ( !( UCSRA & (1<<UDRE)))

;

cmdroutine(0x80);

dataroutine(letter);

/* Put data into buffer, sends the data */

UDR = letter;

letter ++;

}

}



ISR(SIG_UART_RECV)//ISR(USART_RXC_vect)//(USART0_RX_vectXS)

{

unsigned char data;



/* Read the received data */

data = UDR;

cmdroutine(0xC0);

dataroutine(data);

}



HEADER FILES INCLUDED ARE,



#include <stdio.h>

#include <math.h>

#include <avr/io.h>

#include <header.h>

#include <avr/interrupt.h>

#include <avr/signal.h>

#include <inttypes.h>



lcdinitroutine() and cmdroutine() are for LCD..


any comments plzzzzzz

guys it did work using.. the ISR as

SIGNAL (SIG_UART_RECV)

{

unsigned char data;



/* Read the received data */

data = UDR;

cmdroutine(0xC0);

dataroutine(data);

}


thanks

niyaz

You might be also interested in:

:: Interfacing Digital-To-Analog converter to 8086 using 8255
:: Temperature Control system using 8086
:: Traffic light control system using 8086