char ssid[] = "myNetwork";
char pass[] = "myPassword";
int status = WL_IDLE_STATUS;
WiFiServer server(80);
void setup() {
Serial.begin(9600);
Serial.println("Attempting to connect to network…");
Serial.print("SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
while(true);
}
else {
server.begin();
Serial.print("Connected to wifi. My address:");
IPAddress myAddress = WiFi.localIP();
Serial.println(myAddress);
}
}
void loop() {
}
.global main
.type main, @function
main:
ldi r16,255
ldi r17,0
ldi r18,0
startloopnol:
out 0x17,r17
startloop:
in r18,0x12
cpi r18,0
breq startloopnol
out 0x17,r16
rjmp startloop
…
; Define pull-ups and set outputs high
; Define directions for port pins
ldi r16,(1<<PB7)|(1<<PB6)|(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
…
.global main
.type main, @function
main:
ldi r16,255
ldi r17,0
ldi r18,0
out 0x17,r16 ;DDRB
nop
out 0x11,r18 ;DDRD
nop
startloopnol:
out 0x18,r17 ;PORTB
startloop:
in r18,0x12 ;0x12 PORTD, 0x10 PIND
cpi r18,0
breq startloopnol
out 0x18,r16 ;PORTB
rjmp startloop
.global main
.type main, @function
main:
ldi r16,255
ldi r17,0
ldi r18,0
out 0x17,r16 ;DDRB
nop
out 0x11,r18 ;DDRD
nop
startloopnol:
out 0x18,r16 ;PORTB
startloop:
in r18,0x12 ;0x12 PORTD, 0x10 PIND
cpi r18,0
breq startloopnol
out 0x18,r17 ;PORTB
rjmp startloop
avr-gcc -g -Os -mmcu=atmega32a -c test.S
avr-gcc -g -mmcu=atmega32a -o test.elf test.o
avr-objcopy -j .text -j .data -O ihex test.elf test.hex
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e9502 (probably m32)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "test.elf"
avrdude: input file test.elf auto detected as ELF
avrdude: writing flash (138 bytes):
Writing | ################################################## | 100% 0.16s
avrdude: 138 bytes of flash written
avrdude: verifying flash memory against test.elf:
avrdude: load data flash data from input file test.elf:
avrdude: input file test.elf auto detected as ELF
avrdude: input file test.elf contains 138 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.13s
avrdude: verifying …
avrdude: 138 bytes of flash verified
avrdude: safemode: Fuses OK (E:FF, H:99, L:E1)
avrdude done. Thank you.
.global main
.type main, @function
main:
ldi r16,0
ldi r17,255
ldi r18,0
out 0x17,r17 ;DDRB
nop
out 0x11,r16 ;DDRD
nop
;out 0x12,r16 ;PORTD pull-ap resistors
;nop
cbi 0x18,7
startloop:
in r18,0x12 ;0x12 PORTD, 0x10 PIND
cp r18,0
breq case1
out 0x18,r18
rjmp startloop
case1:
out 0x18,r17 ;PORTB
rjmp startloop
.global main
.type main, @function
main:
ldi r16,0
ldi r17,255
ldi r18,0
out 0x17,r17 ;DDRB
nop
out 0x11,r16 ;DDRD
nop
;out 0x12,r16 ;PORTD pull-ap resistors
;nop
cbi 0x18,7
startloop:
in r18,0x10 ;0x12 PORTD, 0x10 PIND
asr r18
brcs case1
out 0x18,r17
rjmp startloop
case1:
out 0x18,r16 ;PORTB
rjmp startloop
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
На самом деле, чтобы научиться писать на асме, не важно на каком, много ума не надо, язык крайне интуитивен и прост. Здесь нет функций, структур, типов данных, все это игрушки дьявола ежжи. Чтобы начать писать под микроконтроллеры, не нужен программатор, какие то там детали, резисторы, диоды, не нужен даже сам микроконтроллер.
Все что понадобится, это:
- avr studio (для конпеляции, бесплатно на atmel.com)
- proteus (для визуального моделирования схем)
- datasheet (есть на сайте атмела для всех контроллеров)
- справочник по командам асм (http://dfe.karelia.ru/koi/posob/avrlab/avrasm-rus.htm)
- какой то анон записал короткие и понятные уроки, разберется даже обезяна ( https://www.youtube.com/playlist?list=PL0IfUQKPGZJTMiIcEBo1TVI0d5BOtF_HU )
- любой учебник по avr asm
Какой контроллер выбрать:
attiny13 - сразу учишься бережно расходовать ресурсы, но даже 1кб памяти это много.
http://www.atmel.com/images/doc2535.pdf
atmega16 - комбайн на котором можно собрать систему управления атомной станцией.
http://www.atmel.com/images/doc2466.pdf
Ну и да, зачем собственно этот тред здесь, а например не в мертвом /s/ или /pr/. Давайте вместе просто хотя бы развиваться, а то один рак кругом. Призываются все, кому хочется размять мозги и новых ощущений.