Documente Academic
Documente Profesional
Documente Cultură
INFORMACION RECOLECTADA.
Lo bsico:
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.
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
Ejemplo:
ISR (INT0)
{
cli(); //CLEAR INTERRUPT
PORTA &= ~(1<<PINA1);
_delay_ms(5000);
sei(); //SET INTERRUPT
TCNT0=0; //Para que vuelva a contar desde 0
}
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.
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.