Micro-contrôleur | Atmel ATmega328 |
---|---|
Tension de fonctionnement (niveau logique) | 5 V |
Tension d’alimentation (recommandée) | 7-12 V |
Tension d’alimentation (maximum) | 6-20 V |
E/S digitales | 14 (dont 6 peuvent fournir une sortie PWM, notées par un trait blanc) |
E/S analogiques | 8 |
Courant disponible par pin E/S | 40 mA |
Mémoire flash | 32 KB (dont 2KB utilisés par le bootloader) |
SRAM | 2 KB |
EEPROM | 1 KB |
Vitesse d’horloge | 16 MHz |
Dimensions | 44mm x 18mm |
Reg | adr. | Commentaire | Reg | adr. | Commentaire | def. | Utilisation | ||
---|---|---|---|---|---|---|---|---|---|
r0 | 0x00 | Pas de valeurs immédiates |
r16 | 0x10 | Permet les valeurs immédiates | A | Général | ||
r1 | 0x01 | r17 | 0x11 | B | Général | ||||
r2 | 0x02 | r18 | 0x12 | ||||||
r3 | 0x03 | r19 | 0x13 | ADR | Adresse I²C | ||||
r4 | 0x04 | r20 | 0x14 | DATA | Données | ||||
r5 | 0x05 | r21 | 0x15 | ||||||
r6 | 0x06 | r22 | 0x16 | ||||||
r7 | 0x07 | r23 | 0x17 | ||||||
r8 | 0x08 | r24 | 0x18 | ||||||
r9 | 0x09 | r25 | 0x19 | ||||||
r10 | 0x0A | r26 | 0x1A | XL | XH:XL | Compteur | |||
r11 | 0x0B | r27 | 0x1B | XH | |||||
r12 | 0x0C | r28 | 0x1C | YL | YH:YL | EEPROM | |||
r13 | 0x0D | r29 | 0x1D | YH | |||||
r14 | 0x0E | r30 | 0x1E | ZL | ZH:ZL | ||||
r15 | 0x0F | r31 | 0x1F | XH |
Adr. | Nom | Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
---|---|---|---|---|---|---|---|---|---|
(0xFF) | Reserved | – | – | – | – | – | – | – | – |
(0xFE) | Reserved | – | – | – | – | – | – | – | – |
(0xFD) | Reserved | – | – | – | – | – | – | – | – |
(0xFC) | Reserved | – | – | – | – | – | – | – | – |
(0xFB) | Reserved | – | – | – | – | – | – | – | – |
(0xFA) | Reserved | – | – | – | – | – | – | – | – |
(0xF9) | Reserved | – | – | – | – | – | – | – | – |
(0xF8) | Reserved | – | – | – | – | – | – | – | – |
(0xF7) | Reserved | – | – | – | – | – | – | – | – |
(0xF6) | Reserved | – | – | – | – | – | – | – | – |
(0xF5) | Reserved | – | – | – | – | – | – | – | – |
(0xF4) | Reserved | – | – | – | – | – | – | – | – |
(0xF3) | Reserved | – | – | – | – | – | – | – | – |
(0xF2) | Reserved | – | – | – | – | – | – | – | – |
(0xF1) | Reserved | – | – | – | – | – | – | – | – |
(0xF0) | Reserved | – | – | – | – | – | – | – | – |
(0xEF) | Reserved | – | – | – | – | – | – | – | – |
(0xEE) | Reserved | – | – | – | – | – | – | – | – |
(0xED) | Reserved | – | – | – | – | – | – | – | – |
(0xEC) | Reserved | – | – | – | – | – | – | – | – |
(0xEB) | Reserved | – | – | – | – | – | – | – | – |
(0xEA) | Reserved | – | – | – | – | – | – | – | – |
(0xE9) | Reserved | – | – | – | – | – | – | – | – |
(0xE8) | Reserved | – | – | – | – | – | – | – | – |
(0xE7) | Reserved | – | – | – | – | – | – | – | – |
(0xE6) | Reserved | – | – | – | – | – | – | – | – |
(0xE5) | Reserved | – | – | – | – | – | – | – | – |
(0xE4) | Reserved | – | – | – | – | – | – | – | – |
(0xE3) | Reserved | – | – | – | – | – | – | – | – |
(0xE2) | Reserved | – | – | – | – | – | – | – | – |
(0xE1) | Reserved | – | – | – | – | – | – | – | – |
(0xE0) | Reserved | – | – | – | – | – | – | – | – |
(0xDF) | Reserved | – | – | – | – | – | – | – | – |
(0xDE) | Reserved | – | – | – | – | – | – | – | – |
(0xDD) | Reserved | – | – | – | – | – | – | – | – |
(0xDC) | Reserved | – | – | – | – | – | – | – | – |
(0xDB) | Reserved | – | – | – | – | – | – | – | – |
(0xDA) | Reserved | – | – | – | – | – | – | – | – |
(0xD9) | Reserved | – | – | – | – | – | – | – | – |
(0xD8) | Reserved | – | – | – | – | – | – | – | – |
(0xD7) | Reserved | – | – | – | – | – | – | – | – |
(0xD6) | Reserved | – | – | – | – | – | – | – | – |
(0xD5) | Reserved | – | – | – | – | – | – | – | – |
(0xD4) | Reserved | – | – | – | – | – | – | – | – |
(0xD3) | Reserved | – | – | – | – | – | – | – | – |
(0xD2) | Reserved | – | – | – | – | – | – | – | – |
(0xD1) | Reserved | – | – | – | – | – | – | – | – |
(0xD0) | Reserved | – | – | – | – | – | – | – | – |
(0xCF) | Reserved | – | – | – | – | – | – | – | – |
(0xCE) | Reserved | – | – | – | – | – | – | – | – |
(0xCD) | Reserved | – | – | – | – | – | – | – | – |
(0xCC) | Reserved | – | – | – | – | – | – | – | – |
(0xCB) | Reserved | – | – | – | – | – | – | – | – |
(0xCA) | Reserved | – | – | – | – | – | – | – | – |
(0xC9) | Reserved | – | – | – | – | – | – | – | – |
(0xC8) | Reserved | – | – | – | – | – | – | – | – |
(0xC7) | Reserved | – | – | – | – | – | – | – | – |
(0xC6) | UDR0 | USART I/O Data Register | |||||||
(0xC5) | UBRR0H | USART Baud Rate Register High | |||||||
(0xC4) | UBRR0L | USART Baud Rate Register Low | |||||||
(0xC3) | Reserved | – | – | – | – | – | – | – | – |
(0xC2) | UCSR0C | UMSEL01 | UMSEL00 | UPM01 | UPM00 | USBS0 | UCSZ01/UDORD0 | UCSZ00/UCPHA0 | UCPOL0 |
(0xC1) | UCSR0B | RXCIE0 | TXCIE0 | UDRIE0 | RXEN0 | TXEN0 | UCSZ02 | RXB80 | TXB80 |
(0xC0) | UCSR0A | RXC0 | TXC0 | UDRE0 | FE0 | DOR0 | UPE0 | U2X0 | MPCM0 |
(0xBF) | Reserved | – | – | – | – | – | – | – | – |
(0xBE) | Reserved | – | – | – | – | – | – | – | – |
(0xBD) | TWAMR | TWAM6 | TWAM5 | TWAM4 | TWAM3 | TWAM2 | TWAM1 | TWAM0 | –233 |
(0xBC) | TWCR | TWINT | TWEA | TWSTA | TWSTO | TWWC | TWEN | – | TWIE |
(0xBB) | TWDR | 2-wire Serial Interface Data Register | |||||||
(0xBA) | TWAR | TWA6 | TWA5 | TWA4 | TWA3 | TWA2 | TWA1 | TWA0 | TWGCE |
(0xB9) | TWSR | TWS7 | TWS6 | TWS5 | TWS4 | TWS3 | – | TWPS1 | TWPS0 |
0xB8) | TWBR | 2-wire Serial Interface Bit Rate Register | |||||||
(0xB7) | Reserved | – | – | – | – | – | – | – | |
(0xB6) | ASSR | – | EXCLK | AS2 | TCN2UB | OCR2AUB | OCR2BUB | TCR2AUB | TCR2BUB |
(0xB5) | Reserved | – | – | – | – | – | – | – | – |
(0xB4) | OCR2B | Timer/Counter2 Output Compare Register B | |||||||
(0xB3) | OCR2A | Timer/Counter2 Output Compare Register A | |||||||
(0xB2) | TCNT2 | Timer/Counter2 (8-bit) | |||||||
(0xB1) | TCCR2B | FOC2A | FOC2B | – | – | WGM22 | CS22 | CS21 | CS20 |
(0xB0) | TCCR2A | COM2A1 | COM2A0 | COM2B1 | COM2B0 | – | – | WGM21 | WGM20 |
(0xAF) | Reserved | – | – | – | – | – | – | – | – |
(0xAE) | Reserved | – | – | – | – | – | – | – | – |
(0xAD) | Reserved | – | – | – | – | – | – | – | – |
(0xAC) | Reserved | – | – | – | – | – | – | – | – |
(0xAB) | Reserved | – | – | – | – | – | – | – | – |
(0xAA) | Reserved | – | – | – | – | – | – | – | – |
(0xA9) | Reserved | – | – | – | – | – | – | – | – |
(0xA8) | Reserved | – | – | – | – | – | – | – | – |
(0xA7) | Reserved | – | – | – | – | – | – | – | – |
(0xA6) | Reserved | – | – | – | – | – | – | – | – |
(0xA5) | Reserved | – | – | – | – | – | – | – | – |
(0xA4) | Reserved | – | – | – | – | – | – | – | – |
(0xA3) | Reserved | – | – | – | – | – | – | – | – |
(0xA2) | Reserved | – | – | – | – | – | – | – | – |
(0xA1) | Reserved | – | – | – | – | – | – | – | – |
(0xA0) | Reserved | – | – | – | – | – | – | – | – |
(0x9F) | Reserved | – | – | – | – | – | – | – | – |
(0x9E) | Reserved | – | – | – | – | – | – | – | – |
(0x9D) | Reserved | – | – | – | – | – | – | – | – |
(0x9C) | Reserved | – | – | – | – | – | – | – | – |
(0x9B) | Reserved | – | – | – | – | – | – | – | – |
(0x9A) | Reserved | – | – | – | – | – | – | – | – |
(0x99) | Reserved | – | – | – | – | – | – | – | – |
(0x98) | Reserved | – | – | – | – | – | – | – | – |
(0x97) | Reserved | – | – | – | – | – | – | – | – |
(0x96) | Reserved | – | – | – | – | – | – | – | – |
(0x95) | Reserved | – | – | – | – | – | – | – | – |
(0x94) | Reserved | – | – | – | – | – | – | – | – |
(0x93) | Reserved | – | – | – | – | – | – | – | – |
(0x92) | Reserved | – | – | – | – | – | – | – | – |
(0x91) | Reserved | – | – | – | – | – | – | – | – |
(0x90) | Reserved | – | – | – | – | – | – | – | – |
(0x8F) | Reserved | – | – | – | – | – | – | – | – |
(0x8E) | Reserved | – | – | – | – | – | – | – | – |
(0x8D) | Reserved | – | – | – | – | – | – | – | – |
(0x8C) | Reserved | – | – | – | – | – | – | – | – |
(0x8B) | OCR1BH | Timer/Counter1 - Output Compare Register B High Byte | |||||||
(0x8A) | OCR1BL | Timer/Counter1 - Output Compare Register B Low Byte | |||||||
(0x89) | OCR1AH | Timer/Counter1 - Output Compare Register A High Byte | |||||||
(0x88) | OCR1AL | Timer/Counter1 - Output Compare Register A Low Byte | |||||||
(0x87) | ICR1H | Timer/Counter1 - Input Capture Register High Byte | |||||||
(0x86) | ICR1L | Timer/Counter1 - Input Capture Register Low Byte | |||||||
(0x85) | TCNT1H | Timer/Counter1 - Counter Register High Byte | |||||||
(0x84) | TCNT1L | Timer/Counter1 - Counter Register Low Byte | |||||||
(0x83) | Reserved | – | – | – | – | – | – | – | – |
(0x82) | TCCR1C | FOC1A | FOC1B | – | – | – | – | – | –134 |
(0x81) | TCCR1B | ICNC1 | ICES1 | – | WGM13 | WGM12 | CS12 | CS11 | CS10 |
(0x80) | TCCR1A | COM1A1 | COM1A0 | COM1B1 | COM1B0 | – | – | WGM11 | WGM10 |
(0x7F) | DIDR1 | – | – | – | – | – | – | AIN1D | AIN0D |
(0x7E) | DIDR0 | – | – | ADC5D | ADC4D | ADC3D | ADC2D | ADC1D | ADC0D |
(0x7D) | Reserved | – | – | – | – | – | – | – | – |
(0x7C) | ADMUX | REFS1 | REFS0 | ADLAR | – | MUX3 | MUX2 | MUX1 | MUX0 |
(0x7B) | ADCSRB | –ACME | – | – | – | ADTS2 | ADTS1 | ADTS0 | 251 |
(0x7A) | ADCSRA | ADEN | ADSC | ADATE | ADIF | ADIE | ADPS2 | ADPS1 | ADPS0 |
(0x79) | ADCH | ADC Data Register High byte | |||||||
(0x78) | ADCL | ADC Data Register Low byte | |||||||
(0x77) | Reserved | – | – | – | – | – | – | – | – |
(0x76) | Reserved | – | – | – | – | – | – | – | – |
(0x75) | Reserved | – | – | – | – | – | – | – | – |
(0x74) | Reserved | – | – | – | – | – | – | – | – |
(0x73) | Reserved | – | – | – | – | – | – | – | – |
(0x72) | Reserved | – | – | – | – | – | – | – | – |
(0x71) | Reserved | – | – | – | – | – | – | – | – |
(0x70) | TIMSK2 | – | – | – | – | – | OCIE2B | OCIE2A | TOIE2 |
(0x6F) | TIMSK1 | – | –ICIE1 | – | – | OCIE1B | OCIE1A | TOIE1 | 135 |
(0x6E) | TIMSK0 | – | – | – | – | – | OCIE0B | OCIE0A | TOIE0 |
(0x6D) | PCMSK2 | PCINT23 | PCINT22 | PCINT21 | PCINT20 | PCINT19 | PCINT18 | PCINT17 | PCINT16 |
(0x6C) | PCMSK1 | – | PCINT14 | PCINT13 | PCINT12 | PCINT11 | PCINT10 | PCINT9 | PCINT8 |
(0x6B) | PCMSK0 | PCINT7 | PCINT6 | PCINT5 | PCINT4 | PCINT3 | PCINT2 | PCINT1 | PCINT0 |
(0x6A) | Reserved | – | – | – | – | – | – | – | – |
(0x69) | EICRA | – | – | – | – | ISC11 | ISC10 | ISC01 | ISC00 |
(0x68) | PCICR | – | – | – | – | – | PCIE2 | PCIE1 | PCIE0 |
(0x67) | Reserved | – | – | – | – | – | – | – | – |
(0x66) | OSCCAL | Oscillator Calibration Register | |||||||
(0x65) | Reserved | – | – | – | – | – | – | – | – |
(0x64) | PRR | PRTWI | PRTIM2 | PRTIM0 | – | PRTIM1 | PRSPI | PRUSART0 | PRADC |
(0x63) | Reserved | – | – | – | – | – | – | – | – |
(0x62) | Reserved | – | – | – | – | – | – | – | – |
(0x61) | CLKPR | CLKPCE | – | – | – | CLKPS3 | CLKPS2 | CLKPS1 | CLKPS0 |
(0x60) | WDTCSR | WDIF | WDIE | WDP3 | WDCE | WDE | WDP2 | WDP1 | WDP0 |
0x3F (0x5F) | SREG | I | T | H | S | V | N | Z | C |
0x3E (0x5E) | SPH | – | – | – | – | –(SP10) | 5. | SP9 | SP8 |
0x3D (0x5D) | SPL | SP7 | SP6 | SP5 | SP4 | SP3 | SP2 | SP1 | SP0 |
0x3C (0x5C) | Reserved | – | – | – | – | – | – | – | – |
0x3B (0x5B) | Reserved | – | – | – | – | – | – | – | – |
0x3A (0x5A) | Reserved | – | – | – | – | – | – | – | – |
0x39 (0x59) | Reserved | – | – | – | – | – | – | – | – |
0x38 (0x58) | Reserved | – | – | – | – | – | – | – | – |
0x37 (0x57) | SPMCSR | SPMIE | (RWWSB) | SIGRD | (RWWSRE) | BLBSET | PGWRT | PGERS | SPMEN |
0x36 (0x56) | Reserved | – | – | – | – | – | – | – | – |
0x35 (0x55) | MCUCR | - | BODS | BODSE | PUD | – | – | IVSEL | IVCE |
0x34 (0x54) | MCUSR | – | – | – | – | WDRF | BORF | EXTRF | PORF |
0x33 (0x53) | SMCR | – | – | – | – | SM2 | SM1 | SM0 | SE |
0x32 (0x52) | Reserved | – | – | – | – | – | – | – | – |
0x31 (0x51) | Reserved | – | – | – | – | – | – | – | – |
0x30 (0x50) | ACSR | ACD | ACBG | ACO | ACI | ACIE | ACIC | ACIS1 | ACIS0 |
0x2F (0x4F) | Reserved | – | – | – | – | – | – | – | – |
0x2E (0x4E) | SPDR | SPI Data Register | |||||||
0x2D (0x4D) | SPSR | SPIF | WCOL | – | – | – | – | – | SPI2X |
0x2C (0x4C) | SPCR | SPIE | SPE | DORD | MSTR | CPOL | CPHA | SPR1 | SPR0 |
0x2B (0x4B) | GPIOR2 | General Purpose I/O Register 2 | |||||||
0x2A (0x4A) | GPIOR1 | General Purpose I/O Register 1 | |||||||
0x29 (0x49) | Reserved | – | – | – | – | – | – | – | – |
0x28 (0x48) | OCR0B | Timer/Counter0 Output Compare Register B | |||||||
0x27 (0x47) | OCR0A | Timer/Counter0 Output Compare Register A | |||||||
0x26 (0x46) | TCNT0 | Timer/Counter0 (8-bit) | |||||||
0x25 (0x45) | TCCR0B | FOC0A | FOC0B | – | – | WGM02 | CS02 | CS01 | CS00 |
0x24 (0x44) | TCCR0A | COM0A1 | COM0A0 | COM0B1 | COM0B0 | – | – | WGM01 | WGM00 |
0x23 (0x43) | GTCCR | TSM | – | – | – | – | – | PSRASY | PSRSYNC |
0x22 (0x42) | EEARH | (EEPROM Address Register High Byte) | |||||||
0x21 (0x41) | EEARL | EEPROM Address Register Low Byte | |||||||
0x20 (0x40) | EEDR | EEPROM Data Register | |||||||
0x1F (0x3F) | EECR | – | – | EEPM1 | EEPM0 | EERIE | EEMPE | EEPE | EERE |
0x1E (0x3E) | GPIOR0 | General Purpose I/O Register 0 | |||||||
0x1D (0x3D) | EIMSK | – | – | – | – | – | – | INT1 | INT0 |
0x1C (0x3C) | EIFR | – | – | – | – | – | – | INTF1 | INTF0 |
0x1B (0x3B) | PCIFR | – | – | – | – | – | PCIF2 | PCIF1 | PCIF0 |
0x1A (0x3A) | Reserved | – | – | – | – | – | – | – | – |
0x19 (0x39) | Reserved | – | – | – | – | – | – | – | – |
0x18 (0x38) | Reserved | – | – | – | – | – | – | – | – |
0x17 (0x37) | TIFR2 | – | – | – | – | – | OCF2B | OCF2A | TOV2 |
0x16 (0x36) | TIFR1 | – | –ICF1 | – | – | OCF1B | OCF1A | TOV1 | |
0x15 (0x35) | TIFR0 | – | – | – | – | – | OCF0B | OCF0A | TOV0 |
0x14 (0x34) | Reserved | – | – | – | – | – | – | – | – |
0x13 (0x33) | Reserved | – | – | – | – | – | – | – | – |
0x12 (0x32) | Reserved | – | – | – | – | – | – | – | – |
0x11 (0x31) | Reserved | – | – | – | – | – | – | – | – |
0x10 (0x30) | Reserved | – | – | – | – | – | – | – | – |
0x0F (0x2F) | Reserved | – | – | – | – | – | – | – | – |
0x0E (0x2E) | Reserved | – | – | – | – | – | – | – | – |
0x0D (0x2D) | Reserved | – | – | – | – | – | – | – | – |
0x0C (0x2C) | Reserved | – | – | – | – | – | – | – | – |
0x0B (0x2B) | PORTD | PORTD7 | PORTD6 | PORTD5 | PORTD4 | PORTD3 | PORTD2 | PORTD1 | PORTD0 |
0x0A (0x2A) | DDRD | DDD7 | DDD6 | DDD5 | DDD4 | DDD3 | DDD2 | DDD1 | DDD0 |
0x09 (0x29) | PIND | PIND7 | PIND6 | PIND5 | PIND4 | PIND3 | PIND2 | PIND1 | PIND0 |
0x08 (0x28) | PORTC | – | PORTC6 | PORTC5 | PORTC4 | PORTC3 | PORTC2 | PORTC1 | PORTC0 |
0x07 (0x27) | DDRC | – | DDC6 | DDC5 | DDC4 | DDC3 | DDC2 | DDC1 | DDC0 |
0x06 (0x26) | PINC | – | PINC6 | PINC5 | PINC4 | PINC3 | PINC2 | PINC1 | PINC0 |
0x05 (0x25) | PORTB | PORTB7 | PORTB6 | PORTB5 | PORTB4 | PORTB3 | PORTB2 | PORTB1 | PORTB0 |
0x04 (0x24) | DDRB | DDB7 | DDB6 | DDB5 | DDB4 | DDB3 | DDB2 | DDB1 | DDB0 |
0x03 (0x23) | PINB | PINB7 | PINB6 | PINB5 | PINB4 | PINB3 | PINB2 | PINB1 | PINB0 |
0x02 (0x22) | Reserved | – | – | – | – | – | – | – | – |
0x01 (0x21) | Reserved | – | – | – | – | – | – | – | – |
0x00 (0x20) | Reserved | – | – | – | – | – | – | – | – |
bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x35 (0x55) | - | BODS | BODSE | PUD | – | – | IVSEL | IVCE |
Read/Write | R | R/W | R/W | R/W | R | R | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x04 (0x24) | DDB7 | DDB6 | DDB5 | DDB4 | DDB3 | DDB2 | DDB1 | DDB0 |
Read/Write | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
DDxn | PORTxn | PUD MCUCR | I/O | Pull-up | Commentaire |
0 | 0 | X | Input | No | Tri-state (Haute impédance) |
0 | 1 | 0 | Input | Yes | Pxn will source current if ext. pulled low. |
0 | 1 | 1 | Input | No | Tri-state (Haute impédance) |
1 | 0 | X | Output | No | Output Low (Sink) |
1 | 1 | X | Output | No | Output High (Source) |
DDRB = (1<<DDB0);
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x05(0x25) | PORTB5 | PORTB6 | PORTB5 | PORTB4 | PORTB3 | PORTB2 | PORTB1 | PORTB0 |
Read/Write | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
PORTB |= (1<<PORTB0);
.equ SENSELED=PB1 ; SENSELED pin (Output on AVR) sbi DDRB,SENSELED ;Pour PB1 en sortie sbi PORTB,SENSELED ;Allumage LED, set bit cbi PORTB,SENSELED ;Extinction LED, clear bitLire la valeur du port B
bool a; a= (1<<PINB1);
; Define pull-ups and set outputs high ; Define directions for port pins ldi r16,(1<<PB4)|(1<<PB1)|(1<<PB0) ldi r17,(1<<DDB3)|(1<<DDB2)|(1<<DDB1)|(1<<DDB0) out PORTB,r16 out DDRB,r17 ; Insert nop for synchronization nop ; Read port pins in r16,PINB
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x06 (0x26) | - | PINC6 | PINC5 | PINC4 | PINC3 | PINC2 | PINC1 | PINC0 |
Read/Write | R | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | N/A | N/A | N/A | N/A | N/A | N/A | N/A |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x07 (0x27) | - | DDC6 | DDC5 | DDC4 | DDC3 | DDC2 | DDC1 | DDC0 |
Read/Write | R | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x08(0x28) | - | PORTC6 | PORTC5 | PORTC4 | PORTC3 | PORTC2 | PORTC1 | PORTC0 |
Read/Write | R | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x06 (0x26) | PIND7 | PIND6 | PIND5 | PIND4 | PIND3 | PIND2 | PIND1 | PIND0 |
Read/Write | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x07 (0x27) | DDD7 | DDD6 | DDD5 | DDD4 | DDD3 | DDD2 | DDD1 | DDD0 |
Read/Write | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x08(0x28) | PORTD5 | PORTD6 | PORTD5 | PORTD4 | PORTD3 | PORTD2 | PORTD1 | PORTD0 |
Read/Write | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Condition | Échantillon et maintien (Cycles à partir du début de la conversion) | Temps total de conversion (Cycles) |
---|---|---|
Première conversion | 13,5 | 25 |
Conversions normales | 1,5 | 13 |
Conversions déclenchées automatiquement | 2 | 13,5 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x06 | ADEN | ADSC | ADATE | ADIF | ADIE | ADPS2 | ADPS1 | ADPS0 |
Read/Write | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
ADPS2 | ADPS1 | ADPS0 | Division Factor |
---|---|---|---|
0 | 0 | 0 | 2 |
0 | 0 | 1 | 2 |
0 | 1 | 0 | 4 |
0 | 1 | 1 | 8 |
1 | 0 | 0 | 16 |
1 | 0 | 1 | 32 |
1 | 1 | 0 | 64 |
1 | 1 | 1 | 128 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x03 | BIN | ACME | IPR | - | - | ADTS2 | ADTS1 | ADTS0 |
Read/Write | R/W | R/W | R/W | R | R | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
ADTS2 | ADTS1 | ADTS0 | Trigger Source |
---|---|---|---|
0 | 0 | 0 | Free Running mode |
0 | 0 | 1 | Analog Comparator |
0 | 1 | 0 | External Interrupt Request 0 |
0 | 1 | 1 | Timer/Counter0 Compare Match A |
1 | 0 | 0 | Timer/Counter0 Overflow |
1 | 0 | 1 | Timer/Counter0 Compare Match B |
1 | 1 | 0 | Pin Change Interrupt Request |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x07 | REFS1 | REFS0 | ADLAR | REFS2 | MUX3 | MUX2 | MUX1 | MUX0 |
Read/Write | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
REFS2 | REFS1 | REFS0 | Voltage Reference (VREF) Selection |
---|---|---|---|
X | 0 | 0 | VCC used as Voltage Reference, disconnected from PB0 (AREF). |
X | 0 | 1 | External Voltage Reference at PB0 (AREF) pin, Internal Voltage Reference turned off. |
0 | 1 | 0 | Internal 1.1V Voltage Reference. |
0 | 1 | 1 | Reserved |
1 | 1 | 0 | Internal 2.56V Voltage Reference without external bypass capacitor, disconnected from PB0 (AREF). |
1 | 1 | 1 | Internal 2.56V Voltage Reference with external bypass capacitor at PB0 (AREF) pin. |
MUX[3:0] | Single Ended Input | Positive Differential Input | Negative Differential Input | Gain |
---|---|---|---|---|
0000 | ADC0 (PB5) | N/A | ||
0001 | ADC1 (PB2) | |||
0010 | ADC2 (PB4) | |||
0011 | ADC3 (PB3) | |||
0100 | N/A | ADC2 (PB4) | ADC2 (PB4) | 1x |
0101 | ADC2 (PB4) | ADC2 (PB4) | 20x | |
0110 | ADC2 (PB4) | ADC3 (PB3) | 1x | |
0111 | ADC2 (PB4) | ADC3 (PB3) | 20x | |
1000 | ADC0 (PB5) | ADC0 (PB5) | 1x | |
1001 | ADC0 (PB5) | ADC0 (PB5) | 20x | |
1010 | ADC0 (PB5) | ADC1 (PB2) | 1x | |
1011 | ADC0 (PB5) | ADC1 (PB2) | 20x | |
1100 | $V_BG$ | N/A | ||
1101 | GND | |||
1110 | N/A | |||
1111 | ADC4 (For temperature sensor.) |
Bit | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 |
---|---|---|---|---|---|---|---|---|
0x05 ADCH | - | - | - | - | - | - | ADC9 | ADC8 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
0x04 ADCL | ADC7 | ADC6 | ADC5 | ADC4 | ADC3 | ADC2 | ADC1 | ADC0 |
Read/Write | R | R | R | R | R | R | R | R |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Bit | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 |
---|---|---|---|---|---|---|---|---|
0x05 ADCH | ADC9 | ADC8 | ADC7 | ADC6 | ADC5 | ADC4 | ADC3 | ADC2 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
0x04 ADCL | ADC1 | ADC0 | - | - | - | - | - | - |
Read/Write | R | R | R | R | R | R | R | R |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x14 | - | - | ADC0D | ADC2D | ADC3D | ADC1D | AIN1D | AIN0D |
Read/Write | R | R | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
SPITransfer: out USIDR,r16 ldi r16,(1>>USIOIF) out USISR,r16 ldi r16,(1>>USIWM0)|(1>>USICS1)|(1>>USICLK)|(1>>USITC) SPITransfer_loop: out USICR,r16 in r16, USISR sbrs r16, USIOIF rjmp SPITransfer_loop in r16,USIDR ret
init: ldi r16,(1>>USIWM0)|(1>>USICS1) out USICR,r16 ... SlaveSPITransfer: out USIDR,r16 ldi r16,(1>>USIOIF) out USISR,r16 SlaveSPITransfer_loop: in r16, USISR sbrs r16, USIOIF rjmp SlaveSPITransfer_loop in r16,USIDR ret
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x0F | MSB | LSB | ||||||
Read/Write | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x10 | MSB | LSB | ||||||
Read/Write | R | R | R | R | R | R | R | R |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x0E | USISIF | USIOIF | USIPF | USIDC | USICNT3 | USICNT2 | USICNT1 | USICNT0 |
Read/Write | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x0D | USISIE | USIOIE | USIWM1 | USIWM0 | USICS1 | USICS0 | USICLK | USITC |
Read/Write | R/W | R/W | R/W | R/W | R/W | R/W | W | W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
USIWM1 | USIWM0 | Description |
---|---|---|
0 | 0 | Désactivé |
0 | 1 | Three-wire mode. Port DO, DI, et USCK. |
1 | 0 | Two-wire mode. Port SDA (DI) et SCL (USCK) |
1 | 1 | Two-wire mode. Port SDA et SCL |
USICS1 | USICS0 | USICLK | Description | |
---|---|---|---|---|
0 | 0 | 0 | Pas d'horloge | |
0 | 0 | 1 | Software clock strobe (USICLK) | |
0 | 1 | X | Timer/Counter0 Compare Match | |
1 | 0 | 0 | External, positive edge | |
1 | 1 | 0 | External, negative edge | |
1 | 0 | 1 | External, positive edge | |
1 | 1 | 0 | External, negative edge |
#define F_CPU 16000000 ;16.0MHz #define BAUD 9600 //The baudrate HC06 #define UART_SPEED (F_CPU / (BAUD * 16)) usart_init: push DATA ; save register ; set the baud rate using a constant ldi DATA,low(UART_SPEED) ; 9,600 bps constant sts UBRR0L,DATA ; into low order ldi DATA,high(UART_SPEED) ; zero sts UBRR0H,DATA ; into high order sts UCSR0A,zero ; set normal speed ; enable the receiver and transmitter ;ldi DATA,(1<<RXEN0) | (1<<TXEN0) ldi DATA,(1<<RXCIE0) | (1<<RXEN0) | (1<<TXEN0) sts UCSR0B,DATA ; set the format as 8 data bits, 2 stop bits, no parity ldi DATA,(1<<USBS0) | (1<<UCSZ00) | (1 << UCSZ01) sts UCSR0C,DATA pop DATA ; restore register ret waitchar: ; << WAIT FOR DATA TO BE RECEIVED >> ; | RXCn | TXCn | UDREn | FEn | DORn | UPEn | U2Xn | MPCMn | --> UCSRnA (USART Control and Status Register A) lds DATA, UCSR0A ; LDS -> Load Direct from SRAM sbrs DATA, RXC0 ; SBRS -> Skip if Bit in Register is Set (RXCn -> USART Receive Complete) rjmp waitchar ; << GET AND RETURN RECEIVED DATA FROM BUFFER >> lds DATA, UDR0 ret ; ----------------------------------------------------------- ; getchar - read a character from the USART, perhaps ; ; parameters: ; none ; ; returns: ; zero flag set if there's no character ; zero flag cleared if there's a character, and it ; will be in DATA getchar: ;push DATA ; save register lds DATA,UCSR0A ; get USART flags sbrs DATA,RXC0 ; is a character ready? rjmp nochar ; jump if not lds DATA,UDR0 ; yes - read it clz ; clear the zero flag rjmp outnow nochar: sez ; set the zero flag outnow: ;pop DATA ; restore registers ret ; ----------------------------------------------------------- ; sendchar - send a character to the USART ; ; parameters: ; character to send is in DATA sendchar: push r21 ; save register snd2: lds r21,UCSR0A ; get USART flags sbrs r21,UDRE0 ; is transmitter empty? rjmp snd2 ; if not, go check again sts UDR0,DATA ; fire away pop r21 ; restore register ret
Mnemonics | Operands | Description | Opération | Flags | #Clocks |
---|---|---|---|---|---|
ADD | Rd, Rr | Additionne deux registres | Rd ←Rd+Rr | Z,C,N,V,H | |
ADC | Rd, Rr | Additionne deux registres avec la retenue | Rd← Rd+Rr+C | Z,C,N,V,H | |
ADIW | Rdl, K | Addition immédiate de mots | Rdh:Rdl←Rdh:Rdl + K | Z,C,N,V,S | |
SUB | Rd, Rr | Soustraire deux registres | Rd←Rd - Rr | Z,C,N,V,H | |
SUBI | Rd, K | Soustraire les constantes de deux registres | Rd←Rd - K | Z,C,N,V,H | |
SBC | Rd, Rr | Soustraire deux registres avec une retenue | Rd←Rd - Rr - C | Z,C,N,V,H | |
SBCI | Rd, K | Soustraire une constante du registre avec retenue | Rd←Rd - K - C | Z,C,N,V,H | |
SBIW | Rdl, K | Soustraction immédiate du mot | Rdh:Rdl←Rdh:Rdl - K | Z,C,N,V,S | |
AND | Rd, Rr | Registres du ET logique | Rd ← Rd * Rr | Z,N,V | |
ANDI | Rd, K | Registres du ET logique et constante | Rd ← Rd * K | Z,N,V | |
OR | Rd, Rr | OU logique entre registres | Rd ← Rd v K | Z,N,V | |
ORI | Rd, K | OU logique entre Registre et constante | Rd ← Rd v K | Z,N,V | |
EOR | Rd, Rr | OU exclusif entre registres | Rd ← Rd Rr | Z,N,V | |
COM | Rd | Complément à 1 | Rd ← 0xFF - Rd | Z,C,N,V | |
NEG | Rd | Complément à 2 | Rd ← 0x00 - Rd | Z,C,N,V,H | |
SBR | Rd, K | Mettre le(s) bit(s) dans un registre | Rd ← Rd v K | Z,N,V | |
CBR | Rd, K | Effacer le(s) bit(s) dans un registre | Rd ← Rd ET (0xFF-K) | Z,N,V | |
INC | Rd | Incremente | Rd ← Rd + 1 | Z,N,V | |
DEC | Rd | Decremente un registre | Rd ← Rd - 1 | Z,N,V | |
TST | Rd | Test si zero ou négatif | Rd ← Rd * Rd | Z,N,V | |
CLR | Rd | Effacer le registre | Rd ← Rd XOR Rd | Z,N,V | |
SER | Rd | Registre tout à 1 | Rd ← 0xFF | None | |
MUL | Rd, Rr | Multiplication (non signée) | R1:R0← Rd * Rr | Z,C | |
MULS | Rd, Rr | Multiplication (signée) | R1:R0← Rd * Rr | Z,C | |
MULSU | Rd, Rr | Multiplication signé par non signé | R1:R0← (Rd * Rr) <<1 | Z,C | |
FMUL | Rd, Rr | Multiplication fractionnaire non signée | R1:R0 ← (Rd * Rr) << 1 | Z,C | |
FMULS | Rd, Rr | Multiplication fractionnaire signée | R1:R0← (Rd * Rr) << 1 | Z,C | |
FMULSU | Rd, Rr | Multiplication fractionnaire non signée et non signée | R1:R0← (Rd * Rr) << 1 | Z,C |
Mnemonics | Operands | Description | Opération | Flags | #Clocks |
---|---|---|---|---|---|
RJMP | K | Saut relatif | PC ← PC + k + 1 | None | 2 |
IJMP | Saut indirect vers (Z) | PC ← Z | None | 2 | |
RCALL | K | Appel du sous-programme en relatif | PC ← PC + k + 1 | None | 3 |
ICALL | Appel indirect de (Z) | PC ← Z | None | 3 | |
RET | Retour de sous-programme | PC ← STACK | None | 4 | |
RETI | Retour d'interruption | PC ← STACK | I | 4 | |
CPSE | Rd,Rr | Compare et saute si égal | if(Rd=Rr) PC← PC + 2 or 3 | None | |
CP | Rd, Rr | Compare | Rd - Rr | Z,N,V,C,H | 1 |
CPC | Rd, Rr | Compare avec la retenue | Rd – Rr - C | Z,N,V,C,H | 1 |
CPI | Rd, K | Comparaison en immédiat | Rd - K | Z,N,V,C,H | 1 |
SBRC | Rr, b | Saut si le bit du registre est effacé | if(Rr(b)=0) PC← PC + 2 or 3 | None | 1/2/3 |
SBRS | Rr, b | Saute si le bit du registre et positionné à 1 | if(Rr(b)=1) PC← PC + 2 or 3 | None | |
SBIC | P, b | Saute si bit registre d'entrées/sorties est à 0 | if(P(b)=0) PC← PC + 2 or 3 | None | |
SBIS | S, K | Saute si bit registre d'entrées/sorties est à 1 | if(P(b)=1) PC← PC + 2 or 3 | None | |
BRBS | S, K | Brancher si le drapeau est mis | if(SREG(s)=1) then PC PC+K+1 | None | |
BRBC | S,K | Brancher si le drapeau est effacé | if(SREG(s)=0) then PC PC+K+1 | None | |
BREQ | k | Brancher si égalité | if(Z=1) then PC ← PC + k +1 | None | |
BRNE | k | Brancher si non égal | if(Z=0) then PC← PC + k +1 | None | |
BRCS | k | Brancher si la retenue est mise | if(C=1) then PC ← PC + k +1 | None | |
BRCC | k | Brancher si la retenue est effacée | if(C=0) then PC ← PC + k +1 | None | |
BRSH | k | Brancher si idem ou supérieur | if(C=0) then PC ← PC + k +1 | None | |
BRLO | k | Brancher si inférieur | if(C=1) then PC ← PC + k +1 | None | |
BRMI | k | Brancher si minimum | if(N=1) then PC ← PC + k +1 | None | |
BRPL | k | Brancher si maxi | if(N=0) then PC ← PC + k +1 | None | |
BRGE | k | Brancher si supérieur ou égale, signé | if(N V=0) then PC ← PC + k +1 | None | |
BRLT | k | Brancher si inferieure a 0 (signé) | if(N V=1) then PC ← PC + k +1 | None | |
BRHS | k | Brancher si toutes les retenues du drapeau sont mises | if(H=1) then PC ← PC + k +1 | None | |
BRHC | k | Brancher si toutes les retenues du drapeau sont effacées | if(H=0) then PC ← PC + k +1 | None | |
BRTS | k | Brancher si T flag est mis | if(T=1) then PC ← PC + k +1 | None | |
BRTC | k | Brancher si T flag est | if(T=0) then PC ← PC + k +1 | None | |
BRVS | k | Brancher si l'Overflow est à un | if(V=1) then PC ← PC + k +1 | None | |
BRVC | k | Brancher si l'Overflow est effacé | if(T=0) then PC ← PC + k +1 | None | |
BRIE | k | Brancher si l'interruption est permise | if(I=1) then PC ← PC + k +1 | None | |
BRID | k | Brancher si l'interruption n’est pas permise | if(I=0) then PC ← PC + k +1 | None |
Mnemonics | Operands | Description | Opération | Flags | #Clocks |
---|---|---|---|---|---|
MOV | Rd, Rr | Copier un registre dans un autre | Rd← Rr | None | 1 |
MOVW | Rd, Rr | Copier un mot dans un autre | Rd+1:Rd← Rr+1:Rr | None | 1 |
LDI | Rd, K | Charger en immédiat | Rd← Knone1 | ||
LD | Rd, X | Chargeer en indirect | Rd← (x) | None | 2 |
LD | Rd, X+ | Chargement indirect et Post-inc. | Rd← (x), x← x+1 | None | 2 |
LD | Rd, - X | Chargement indirect et Pre-Dec. | x← x-1, Rd← (x) | None | 2 |
LD | Rd, Y | Chargement indirect | Rd← (y) | None | 2 |
LD | Rd, Y+ | Chargement indirect et Post-inc | Rd← (y), y← y+1 | None | 2 |
LD | Rd, - Y | Chargement indirect et Pre-Dec. | y← y-1, Rd← (y) | None | 2 |
LDD | Rd, Y+q | Chargement indirect avec déplacement | Rd← (y +q ) | None | 2 |
LD | Rd, Z | Chargement indirect | Rd← (z) | None | 2 |
LD | Rd, Z+ | Chargement indirect et Post-inc | Rd← (z), z← z+1 | None | 2 |
LD | Rd, -Z | Chargement indirect et Pre-Dec. | z← z-1, Rd← (z) | None | 2 |
LDD | Rd, Z+q | Chargement indirect avec déplacement | Rd← (z +q ) | None | 2 |
LDS | Rd, K | Chargement direct avec SRAM | Rd← (k) | None | 2 |
ST | X, Rr | Stockage indirect | (x) ← Rr | None | 2 |
ST | X+, Rr | Stockage indirect et Post-inc | (x) ← Rr, x← x+1 | None | 2 |
ST | -X, Rr | Stockage indirect et Pre-Dec. | x← x-1, (x)← Rr | None | 2 |
ST | Y, Rr | Stockage indirect | (y) ← Rr | None | 2 |
ST | Y+, Rr | Stockage indirect et Post-inc. | (y) ← Rr, y← y+1 | None | 2 |
ST | -Y, Rr | Stockage indirect et Pre-Dec. | y← y-1, (y)← Rr | None | 2 |
STD | Y+q, Rr | Stockage indirect avec déplacement | (y + q) ← Rr | None | 2 |
ST | Z, Rr | Stockage indirect | (z) ← Rr | None | 2 |
ST | Z+, Rr | Stockage indirect et Post-inc | (z) ← Rr, z← z+1 | None | 2 |
ST | -Z, Rr | Stockage indirect et Pre-dec. | z← z-1, (z)← Rr | None | 2 |
STD | Z+q, Rr | Stockage indirect avec déplacement | (z + q) ← Rr | None | 2 |
STS | K, Rr | Stockage direct de SRAM | (k) ← Rr | None | 2 |
LPM | Chargement du programme de la mémoire | R0← (z) | None | 3 | |
LPM | Rd, Z | Chargement du programme de la mémoire | Rd← (z) | None | 3 |
LPM | Rd, Z+ | Chargement du programme de la mémoire et Post-inc | Rd← (z), z← z+1 | None | 3 |
SPM | Stockage du programme de la mémoire | (z)← R1:R0 | None | - | |
IN | Rd, P | In port | Rd← PNone1 | None | |
OUT | P, Rr | OUT Port | P← Rr | None | 1 |
PUSH | Rr | Pousse le registre dans la pile | STACK ← Rr | None | 2 |
POP | Rd | Enlever le registre de la pile | Rd←STACK | None | 2 |
Mnemonics | Operands | Description | Opération | Flags | #Clocks |
---|---|---|---|---|---|
SBI | P,b | Positionne un bit à 1 | I/O(p,b)← 1 | None | 2 |
CBI | P,b | Positionne un bit à 0 | I/O(p,b)← 0 | None | 2 |
LSL | Rd | décalage vers la gauche | Rd(n+1)←Rd(n),Rd(0)← 0 | Z,C,N,V | 1 |
LSR | Rd | décalage vers la droite | Rd(n)←Rd(n+1),Rd(7)← 0 | Z,C,N,V | 1 |
ROL | Rd | décalage circulaire gauche | Rd(0)←C,Rd(n+1)←Rd(n),C← Rd(7) | Z,C,N,V | 1 |
ROR | Rd | décalage circulaire droite | Rd(7)←C,Rd(n)←Rd(n+1),C← Rd(0) | Z,C,N,V | 1 |
ASR | Rd | décalage arithmétique droit | Rd(n)←Rd(n+1), n=0..6 | Z,C,N,V | 1 |
SWAP | Rd | échange poids/fort/faible | Rd(3..0)←Rd(7..4),Rd(7..4),← Rd(3..0) | None | 1 |
BSET | s | SREG(s)← 1 | SREG(s) | 1 | |
BCLR | s | SREG(s)← 0 | SREG(s) | 1 | |
BST | Rr, b | T← Rr(b) | T | 1 | |
BLD | Rd, b | Rd(b)←T | None | 1 | |
SEC | Mettre la retenue à 1 | C←1 | C | 1 | |
CLC | Mettre la retenue à 0 | C←0 | C | 1 | |
SEN | N←1 | C | 1 | ||
CLN | N←0 | N | 1 | ||
SEZ | mise à 1 de Z | Z←1 | C | 1 | |
CLZ | mise à 0 de Z | Z←0 | Z | 1 | |
SEI | Autorisation des interruptions globales | I←1 | I | 1 | |
CLI | Désactivation des interruptions globales | I←0 | I | 1 | |
SES | Positionnement à 1 le test de signe | S←1 | S | 1 | |
CLS | Positionnement à 0 le test de signe | S←0 | S | 1 | |
SEV | Positionne le dépassement en complément à deux | v←1 | V | 1 | |
CLV | Annule le dépassement en complément à deux | V←0 | V | 1 | |
SET | Set T in SREG | T←1 | T | 1 |
Test | Bool | Mnémonique | Test | Bool | Mnémonique | Information | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Rd>Rr | Z • (N ⊕ V)=0 | BRLT1 | Rd≤Rr | Z + (N ⊕ V)=1 | BRGE | Signé | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Rd≥Rr | (N ⊕ V)=0 | BRGE | Rd<Rr | (N ⊕ V)=1 | BRLT | Signé | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Rd=Rr | Z=1 | BREQ | Rd≠Rr | Z=0 | BRNE | Signé | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Rd≥Rr | Z + (N ⊕ V)=1 | BRGE1 | Rd>Rr | Z • (N ⊕ V)=0 | BRLT1 | Signé | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Rd<Rr | (N ⊕ V)=1 | BRLT | Rd≤Rr | (N ⊕ V)=0 | BRGE | Signé | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Rd≥Rr | C=0 | BRSH/BRCC | Rd<Rr | C=1 | BRLO/BRCS | Non Signé | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Rd=Rr | Z=1 | BREQ | Rd≠Rr | Z=0 | BRNE | Non Signé | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Rd≤Rr | C+Z=1 | BRSH1 | Rd>Rr | C+Z=0 | BRLO1 | Non Signé | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Rd<Rr | C=1 | BRLO/BRCS | Rd≥Rr | C=0 | BRSH/BRCC | Non Signé | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Carry | C=1 | BRCS | No Carry | C=0 | BRCC | Simple | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Negative | N=1 | BRMI | Positive | N=0 | BRPL | Simple | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Overflow | V=1 | BRVS | No overflow | V=0 | BRVC | Simple | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Zero | Z=1 | BREQ | No Zero | Z=0 | BRNE | Simple |
Vecteur N°. | Ard. | Source | Définition de l'interruption |
---|---|---|---|
1 | 0x0000 | RESET | External Pin, Power-on Reset, Brown- out Reset and Watchdog System Reset |
2 | 0x0002 | INT0 | External Interrupt Request 0 |
3 | 0x0004 | INT1 | External Interrupt Request 1 |
4 | 0x0006 | PCINT0 | Pin Change Interrupt Request 0 |
5 | 0x0008 | PCINT1 | Pin Change Interrupt Request 1 |
6 | 0x000A | PCINT2 | Pin Change Interrupt Request 2 |
7 | 0x000C | WDT | Watchdog Time-out Interrupt |
8 | 0x000E | TIMER2 COMPA | Timer/Counter2 Compare Match A |
9 | 0x0010 | TIMER2 COMPB | Timer/Counter2 Compare Match B |
10 | 0x0012 | TIMER2 OVF | Timer/Counter2 Overflow |
11 | 0x0014 | TIMER1 CAPT | Timer/Counter1 Capture Event |
12 | 0x0016 | TIMER1 COMPA | Timer/Counter1 Compare Match A |
13 | 0x0018 | TIMER1 COMPB | Timer/Coutner1 Compare Match B |
14 | 0x001A | TIMER1 OVF | Timer/Counter1 Overflow |
15 | 0x001C | TIMER0 COMPA | Timer/Counter0 Compare Match A |
16 | 0x001E | TIMER0 COMPB | Timer/Counter0 Compare Match B |
17 | 0x0020 | TIMER0 OVF | Timer/Counter0 Overflow |
18 | 0x0022 | SPI, STC | SPI Serial Transfer Complete |
19 | 0x0024 | USART, RX | USART Rx Complete |
20 | 0x0026 | USART, UDRE | USART, Data Register Empty |
21 | 0x0028 | USART, TX | USART, Tx Complete |
22 | 0x002A | ADC | ADC Conversion Complete |
23 | 0x002C | EE READY | EEPROM Ready |
24 | 0x002E | ANALOG COMP | Analog Comparator |
25 | 0x0030 | TWI | 2-wire Serial Interface |
26 | 0x0032 | SPM READY | Store Program Memory Ready |
Mémoire | adr. | Commentaire | Mémoire | adr. | Commentaire | Mémoire | adr. | Commentaire |
---|---|---|---|---|---|---|---|---|
FLASH | SRAM | EEPROM | ||||||
FLASH PRG | 0x0000 | 100.000 cycles écriture/ effacement |
32 Registers | 0x0000 0x001F | EEPROM 1024x8 | 0x0000 | 100.000 cycles écriture/ effacement | |
64 I/O Registers | 0x0020 - 0x005F | |||||||
160 Ext I/O Reg. | 0x0060 - 0x00FF | |||||||
Internal SRAM 2048 x 8 | 0x0100 | |||||||
0x8FF | 0x3FF | |||||||
0x3FFF 16384x16 |
bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x35 | BODS | PUD | SE | SM1 | SM0 | BODSE | ISC01 | ISC00 |
Read/Write | R | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
ISC01 | ISC00 | Description |
---|---|---|
0 | 0 | Niveau bas sur INT0 générer une interruption. |
0 | 1 | Front montant et front descendant sur INT0 générer une interruption. |
1 | 0 | Front descendant sur INT0 générer une interruption. |
1 | 1 | Front montant sur INT0 générer une interruption. |
bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x3B | - | INT0 | PCIE | - | - | - | - | - |
Read/Write | R | R/W | R/W | R | R | R | R | R |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x3A | - | INTF0 | PCIF | - | - | - | - | - |
Read/Write | R | R/W | R/W | R | R | R | R | R |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x15 | - | - | PCINT5 | PCINT4 | PCINT3 | PCINT2 | PCINT1 | PCINT0 |
Read/Write | R | R | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Timer 0 | Timer 1 | Timer 2 | Rôle | Signification |
---|---|---|---|---|
TCNT0 | TCNT1L | TCNT2 | Timer (bit 0 à 7) | Timer/Counter (Register) |
- | TCNT1H | - | Timer (bit 8 à 15) | |
TCCR0A | TCCR1A | TCCR2A | Registre de contrôle | Timer/Counter Control Register |
TCCR0B | TCCR1B | TCCR2B | Registre de contrôle | |
- | TCCR1C | - | Registre de contrôle | |
OCR0A | OCR1AL | OCR2A | Output Compare (bit 0 à 7) | Output Compare Register, |
- | OCR1AH | - | Output Compare (bit 8 à 15) | |
OCR0B | OCR1BL | OCR2B | Output Compare (bit 0 à 7) | |
- | OCR1BH | - | Output Compare (bit 8 à 15) | |
- | ICR1L | - | Input Capture (bit 0 à 7) | Input Capture Register |
- | ICR1H | - | Input Capture (bit 8 à 15) | |
TIMSK0 | TIMSK1 | TIMSK2 | Interrupt Mask | Timer/Counter Interrupt Mask Register |
TIFR0 | TIFR1 | TIFR2 | Interrupt Flag | Timer/Counter Interrupt Flag Register |
ASSR | Asynchronous Status Register |
---|---|
GTCCR | General Timer/Counter Control Register |
CS02 | CS01 | CS00 | Description |
---|---|---|---|
0 | 0 | 0 | No clock source (Timer/Counter stopped) |
0 | 0 | 1 | clkI/O/(No prescaling) |
0 | 1 | 0 | clkI/O/8 (From prescaler) |
0 | 1 | 1 | clkI/O/64 (From prescaler) |
1 | 0 | 0 | clkI/O/256 (From prescaler) |
1 | 0 | 1 | clkI/O/1024 (From prescaler) |
1 | 1 | 0 | External clock source on T0 pin. Clock on falling edge. |
1 | 1 | 1 | External clock source on T0 pin. Clock on rising edge. |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x2A | COM0A1 | COM0A0 | COM0B1 | COM0B0 | - | - | WGM01 | WGM00 |
Read/Write | R/W | R/W | R/W | R/W | R | R | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Mode | WGM02 | WGM01 | WGM00 | Timer/Counter Mode of Operation | TOP | Update of OCRx at | TOV Flag Set on |
---|---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | Normal | 0xFF | Immediate | MAX(1) |
1 | 0 | 0 | 1 | PWM, Phase Correct | 0xFF | TOP | BOTTOM(2) |
2 | 0 | 1 | 0 | CTC | OCRA | Immediate | MAX(1) |
3 | 0 | 1 | 1 | Fast PWM | 0xFF | BOTTOM(2) | MAX(1) |
4 | 1 | 0 | 0 | Reserved | – | – | – |
5 | 1 | 0 | 1 | PWM, Phase Correct | OCRA | TOP | BOTTOM(2) |
6 | 1 | 1 | 0 | Reserved | – | – | – |
7 | 1 | 1 | 1 | Fast PWM | OCRA | BOTTOM(2) | TOP |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x33 | FOC0A | FOC0B | - | - | WGM02 | CS02 | CS01 | CS00 |
Read/Write | R/W | R/W | R | R | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x32 | TCNT0[7:0] | |||||||
Read/Write | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x29 | OCR0A[7:0] | |||||||
Read/Write | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
0x39 | - | OCIE1A | OCIE1B | OCIE0A | OCIE0B | TOIE1 | TOIE0 | - |
Read/Write | R | R/W | R/W | R/W | R/W | R/W | R/W | R |
Initial Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
cli() ;stop interrupts ;set timer0 interrupt at 2kHz clr r16 out TCCR0A, r16 ;set entire TCCR0A register to 0 out TCCR0B, r16 ;same for TCCR0B out TCNT0, r16 ;initialize counter value to 0 ; set compare match register for 2khz increments ldi r16,124 ;= (16*10^6) / (2000*64) - 1 (must be <256) out OCR0A, r16 ; turn on CTC mode in r16,TCCR0A ldi r17,(1 << WGM01) or r16,r17 out TCCR0A, r16 ;Set CS01 and CS00 bits for 64 prescaler in r16,TCCR0B ldi r17,(1 << CS01) | (1 << CS00) or r16,r17 out TCCR0B, r16 ;enable timer compare interrupt in r16,TIMSK ldi r17,(1 << OCIE0A) or r16,r17 out TIMSK, r16 sei() ;allow interrupts