Mostrando entradas con la etiqueta Microcontroller. Mostrar todas las entradas
Mostrando entradas con la etiqueta Microcontroller. Mostrar todas las entradas

jueves, 13 de agosto de 2009

Timer,Usart,Interrupt Basic Steps

While coding for timers Usart etc there are some steps that are always rather generally taken in order to initialize them.

I have tried to just summarize these basic steps for the beginner which they can adopt while writing code for AVR (i use ATmega 8)

Timer

1. Set the prescalar TCCR0 (example using timer0)
2. Enable the timer interrupt TIMSK timer mask register
3. Enable global interrupts
4. Calculate how often OVF interrupt is thrown as timer OVF is periodic in nature


Usart

INIT

1. Set the baud rate register UBRR is 16 bit
2. Enable Receiver and Transmitter UCSRB also enable the RXCIE or TXCIE or both if interrupts are required.
3. Set frame format for assynchronous communication UCSRC.
that is if you are using parity bits or not,which form of start & stop bit are you trying to incorporate


Transmit
1. UCSRA&(1<<UDRE). If done than store the data to be transmitted in the UDR(usart data register).

Receive
1. Check if receive is complete if yes then store the data from the UDR to any variable

further if using the interrupts related to usart events then make sure you enable the global interrupt by SEI();


Disabling the interrupt before atomic statements.

1. Method is to store the status or condition of the MCU by saving the SREG into any 8 bit variable
2. Use _CLI() to clear global interrupt enable bit
3. Restore previous state form variable used in 1.


PWM hardware based

1. Initialize all the timer in the desired pwm mode and set whether you want inverting or non-inverting pwm.
2. Set the prescalar in TCCR1B.wgm13=0 means normal mode.That is timer would start then OVF and then restart from BOTTOM.
3. Set OCR1A/B a 16 bit register
4. Duty cycle is dependent only on OCR values




viernes, 24 de julio de 2009

Counter using atmega 8

Enjoyed previous videos???
I programmed atmega8 along with my friend divya alok (class mate) to display numbers (0-9) on a 7 Segment Led.

This is also based on simple I/O pin control




I Hope that you liked it.
Good Day

lunes, 13 de julio de 2009

ROBOTICS BOOK DOWNLOAD 150+


ROBOTICS

Ever found interest in building your own ROBOT the visit the following link.

Download this text file containing to 150+ books

I am in no way hosting links given in the text file.If it violates any norms please inform me.I don't have much inf with copyrights.Thanks for your co-operation