AVR Digital pin read write

AVR Digital pin read write
Çeşme:
https://www.youtube.com/channel/UC-0qkpPo5Des2nkN60QGrLQ
http://microchipdeveloper.com/8avr:alu
https://www.microchip.com/webdoc/avrassembler/avrassembler.wb_instruction_list.html
https://www.microchip.com/webdoc/avrassembler/avrassembler.wb_directives.html
http://www.avrbeginners.net/
http://www.avr-asm-tutorial.net/avr_en/beginner/index.html
http://www.microchip.com/developmenttools/productdetails.aspx?partno=flip
https://medium.com/jungletronics/meeting-assembly-hello-world-arduino-blinking-code-330386652309
https://medium.com/jungletronics/how-to-load-programs-to-an-arduino-uno-from-atmel-studio-7-83c8dd8d175d
https://www.youtube.com/watch?v=SDQmCWE65eI&list=PLc2rvfiptPSRHQ0Kn1M8mPjp6ihWAOOYU&index=2
  1. Arduino UNO
#define PIN_COUNT 6 int inputPins[6] = {2,3,4,5,6,7}; int outputPins[6] = {8,9,10,11,12,13}; int i; void setup() { pinMode(A0, INPUT_PULLUP); pinMode(A1, OUTPUT); for (i = 0; i < PIN_COUNT; i++) { pinMode(inputPins[i], INPUT_PULLUP); pinMode(outputPins[i], OUTPUT); } } void loop() { digitalWrite(A1, !digitalRead(A0)); for (i = 0; i < PIN_COUNT; i++) { digitalWrite(outputPins[i], !digitalRead(inputPins[i])); } }
#define F_CPU 16000000L #include <avr/io.h> #include <util/delay.h> int main(void) { DDRC = 0x02; PORTC |= (1<<PC0); DDRD = 0x00; PORTD = 0xFC; DDRB = 0x3F; while (1) { PORTB = (PIND>>2); if ((PINC & (1<<PC0)) == 0) { PORTC |= (1<<PC1); } else { PORTC &= ~(1<<PC1); } } }
.org $0 rjmp start start: ldi r16, $02 out ddrc, r16 sbi portc, 0 ; Set Bit to PC0 ldi r16, $00 out ddrd, r16 ldi r16, $fc out portd, r16 ldi r16, $3f out ddrb, r16 while: sbis pinc, 0 ; Skip if Bit in I/O Register is Set sbi portc, 1 sbic pinc, 0 ; Skip if Bit in I/O Register is Cleared cbi portc, 1 ; Clear bit 7 in Port D in r16, pind ; Load an I/O Location to Register lsr r16 ; Logical Shift Right lsr r16 out portb, r16 rjmp while .exit
#chip mega328p, 16 dir portc.0 in dir portc.1 out dir portd.2 in dir portd.3 in dir portd.4 in dir portd.5 in dir portd.6 in dir portb.0 out dir portb.1 out dir portb.2 out dir portb.3 out dir portb.4 out do Forever: If portc.0 = 1 Then set pinc.1 on Else set pinc.1 off End If portb.0 = pind.2 portb.1 = pind.3 portb.2 = pind.4 portb.3 = pind.5 portb.4 = pind.6 loop