Sie sind auf Seite 1von 7

ATMEL

INFORMACION RECOLECTADA.

Mediante el datasheet se pueden conocer varias


configuraciones con las que viene predeterminado el
microcontrolador ATMEL, otra opcin, es descargando el
programa AVR DUDE, el cual te permite conocer el estado de
los fuses, los cuales te dan las configuraciones exactas que
contiene el microcontrolador.

Configuraciones como: CLK DIV (DIVISION DEL OSCILADOR),


INT RC (OSCILADOR INTERNO), EXT CLK (OSCILADOR
EXTERNO), JTAG INTERFACE (INTERFACE PARA DISPOSITIVO
JTAG, QUE TE DESHABILITA ALGUNOS PINES DEL
MICROCONTROLADOR), SPI (SERIAL PROGRAM INTERFACE),
BROWN OUT (DETECCION DE NIVEL DE VOLTAJE) y otras mas.

Conociendo esas configuraciones predeterminadas es que


podrs comenzar a desarrollar el software y el hardware que
se adapten a esas configuraciones modificarlas a tu
conveniencia para un fin del proyecto que necesites.

Para conocer el estado de los FUSES, que son los encargados


de decirte las configuraciones predeterminadas, abres el
programa AVR DUDE y le das en FUSE SETTING, recuadro rojo
de la imagen, ese link te llevara a una pagina web que
colocando la identificacin de tu microcontrolador te indica
las configuraciones predeterminadas, y al final de la pagina
los FUSES, que debe tener activo con esas configuraciones, en
esa misma pagina cambiando las configuraciones a tu
conveniencia puedes ver que a medida que se cambian las
configuraciones se cambian los FUSES, con esos FUSES ya
configurados a tu conveniencia podrs tomar el valor de cada
uno de ellos para as PROGRAMARSELO A TU
MICROCONTROLADOR y que se configure a tu conveniencia.
Para hacerlo el primer paso es colocar el nombre de tu
programador en el programa AVR DUDE como lo muestra la
imagen en la flecha 1, lo segundo es colocar el puerto, lo
tercero es darle a DETECT, este te indicara el nombre del
microcontrolador, luego podrs leer los FUSES, presionando
READ en el circulo de la imagen y ah te aparecern los fuses,
ah mismo podrs editar los FUSES para colocarlos igual a las
preferencias elegidas en la pagina web que te arroja los
FUSES a tu conveniencia.

Nota: En microcontroladores MICROCHIP O PIC los fuses se


pueden modificar en el programa mediante #FUSES. EJEMPLO:
#FUSES XT,BROWNOUT,NOLVP,NOWDT. En los
microcontroladores ATMEL estos FUSES deben ser
programados como lo antes explicados.
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////

Luego de conocido todo lo anterior puedes comenzar a


desarrollar el programa, en conjunto con el hardware.

Lo bsico:

Configurar los pines de los puertos


como entradas o como salidas.
Segn la teora en ingles que se encuentra al final indica que
el registro DDRX es el utilizado para configurar los pines del
puerto, dice que si se coloca en 1 es salida y en 0 entrada.

Ejemplo: DDRD |= 0b11110000; Coloque desde D0 a D4 como


entrada y desde D5 hasta D8 como salida. (PUERTO D)

DDRA |= 0b11111111; Coloque todos como


salidas. (PUERTO A)

DDRB |= 0b00000000; Coloque todos como


entradas. (PUERTO B)

Enviar mediante los pines pulsos


altos (5V) o pulsos bajos (0V).
Segn la teora si un pin es configurado como salida y es el
respectivo bit de PORTX es puesto en 1 lgico, el respectivo
pin del puerto es colocado en alto (5V). De igual forma si es
escrito 0 lgico.

Ejemplo: PORTA |= (1<<PINA7); PIN A7 colocado en ALTO


(5V)

PORTA &= ~ (1<<PINA6); PIN A6 colocado en BAJO


(0V).
Leer o conocer el estado de los pines
de un puerto del microcontrolador.
Segn la teora el registro PINX es el usado para retornar el
valor lgico disponible en el pin del puerto.

Ejemplo: IF ( (PIND & (1<<PIND3)) ) As pregunto por un 1


lgico o estado ALTO (5V).

IF (! (PIND & (1<<PIND2)) ) As pregunto por un 0


lgico o estado BAJO (0V).

http://www.atmel.com/Images/Atmel-42482-Getting-Started-with-
ATmega328PB_Application%20Note_AT08401.pdf

Code explanation: Each PORT has three registers DDRx, PORTx, and PINx
The DDRx register is used to configure the port pin direction. 1 -
Output; 0 - Input. If one pin is configured as output pin and if the
respective bit in PORTx is written logic one, the respective port pin is driven
high. If the same bit is written logic zero, the pin will be driven low. The
PINx register is used to return the logic level available on the port pin.

//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////

Recomendacin para pines que no se


utilizaran:
El mtodo mas simple para definirle un nivel a un pin sin uso
es establecer el internal pull up resistor. Conectar pines sin
uso directamente a VCC o GND no es recomendado, puede
causar excesivas corrientes si el pin es configurado
accidentalmente como salida. (SEGN TEORIA EN INGLES AL
FINALIZAR ESTA ETAPA)

Si el PORTX es escrito un 1 logico cuando ese pin es


configurado como entrada, el internal pull up resistor es
activada.

Ejemplo: DDRA |= 0b11111011; A2 colocado como entrada

PORTA |= (1<<PINA2); A2 colocado en estado


ALTO (5V)
15.2.6. Unconnected Pins
If some pins are unused, it is recommended to ensure that these pins
have a defined level. Even though most of the digital inputs are
disabled in the deep sleep modes as described above, floating inputs
should be avoided to reduce current consumption in all other modes
where the digital inputs are enabled (Reset, Active mode and Idle
mode).
The simplest method to ensure a defined level of an unused
pin, is to enable the internal pull-up. In this case, the pull-up will
be disabled during reset. If low power consumption during reset is
important, it is recommended to use an external pull-up or pull-down.
Connecting unused pins directly to VCC or GND is not
recommended, since this may cause excessive currents if the
pin is accidentally configured as an output.

Configuring the Pin


If PORTxn is written to '1' when the pin is configured as an
input pin, the pull-up resistor is activated. To switch the pull-up
resistor off, PORTxn has to be written to '0' or the pin has to be
configured as an output pin.
INTERRUPCIONES, TIMERS Y DATA
TYPES.
Lo principal para activar cualquier interrupcin es habilitar el
primer bit (I-bit) del estado de registro (STATUS REGISTER)
como lo dice la teora al finalizar. Una forma de hacerlo es
colocar las instrucciones SEI o CLI para activar o desactivar.

Ejemplo:
ISR (INT0)
{
cli(); //CLEAR INTERRUPT
PORTA &= ~(1<<PINA1);
_delay_ms(5000);
sei(); //SET INTERRUPT
TCNT0=0; //Para que vuelva a contar desde 0
}

Antes que eso se debe habilitar la interrupcin particular que


se desee, el datasheet del microcontrolador a utilizar indica
como habilitar la interrupcin particular que se desea.

(DATASHEET DE CUALQUIER MICROCONTROLADOR ATMEL)

Status Register
The Status Register contains information about the result of the most
recently executed arithmetic instruction. This information can be used
for altering program flow in order to perform conditional operations.
The Status Register is updated after all ALU operations, as specified in
the Instruction Set Reference. This will in many cases remove the
need for using the dedicated compare instructions, resulting in faster
and more compact code.
The Status Register is not automatically stored when entering an
interrupt routine and restored when returning from an interrupt. This
must be handled by software.

Bit 7 I: Global Interrupt Enable


The Global Interrupt Enable bit must be set for the interrupts to be
enabled. The individual interrupt enable control is then performed in
separate control registers. If the Global Interrupt Enable Register is
cleared, none of the interrupts are enabled independent of the
individual interrupt enable settings. The Ibit is cleared by hardware
after an interrupt has occurred, and is set by the RETI instruction to
enable subsequent interrupts. The I-bit can also be set and cleared by
the application with the SEI and CLI instructions, as described in the
instruction set reference.

INFORMACION EXTRA PARA


INTERRUPCIONES.
http://www.atmel.com/Images/Atmel-8468-Using-External-
Interrupts-for-megaAVR-
Devices_ApplicationNote_AVR1200.pdf
Interrupt Priority Priority for the interrupts is determined by the interrupt
vector address. An interrupt with lowest interrupt vector address has the
highest priority. So reset has the highest priority followed by INT0, then INT1
and so on. If two interrupts occurs simultaneously, then the interrupt with
higher priority is served first.
Lista de interrupciones por orden de prioridad en datasheet Atmega644PV
PAG 78

Before enabling an interrupt, it is recommended to clear the flag bit


of the corresponding interrupt because when the flag bit is set, the
interrupt will be triggered the moment we enable the interrupt.

If enabled, interrupts will be triggered even when the pins are


configured as outputs. This provides a way of generating a software
interrupt.
If a logic high level (one) is present on an asynchronous external interrupt
pin configured as Interrupt on Rising Edge, Falling Edge, or Any Logic
Change on Pin while the external interrupt is not enabled, the
corresponding External Interrupt Flag will be set when resuming from the
powerdown, power-save, and standby sleep modes.

Once the CPU enters the ISR, the global interrupt enable bit (I-bit) in SREG
will be cleared so that all other interrupts are disabled.

INFORMACION EXTRA PARA DATA


TYPES AND SIZES.
http://www.atmel.com/Images/doc8453.pdf

INFORMACION EXTRA PARA TIMERS.


http://www.atmel.com/Images/Atmel-2505-Setup-and-Use-
of-AVR-Timers_ApplicationNote_AVR130.pdf

Das könnte Ihnen auch gefallen