MCU avrgcc MCU ATMega 168 avrgcc mmcuatmega 168
- Slides: 54
������� MCU • ����� avr-gcc ���������� MCU ����� ATMega 168 $ avr-gcc -mmcu=atmega 168 -o myprog. elf myprog. c • ���������� $ avr-objcopy -j. text -j. data -O ihex myprog. elf myprog. hex executable $ avrdude -p atmega 168 -c usbasp -U flash: w: myprog. hex • ���������� 6
������ ������� C 99 ������ ( (���� ( (��� �� char int 8_t 8 ��������� -128 +127 unsigned char uint 8_t 8 0 255 short int 16_t 16 -32, 768 +32, 767 uint 16_t 16 0 65, 535 int - 16/32 -32, 768/-2, 147, 483, 648 unsigned int - 16/32 0 int 32_t 32 -2, 147, 483, 648 uint 32_t 32 0 long int 64_t 64 − 9, 223, 372, 036, 854, 775, 808 +9, 223, 372, 036, 854, 775, 807 unsigned long uint 64_t 64 0 18, 446, 744, 073, 709, 551, 615 unsigned short long unsigned long +32, 767/+2, 147, 483, 647 65, 535 ��� 4, 294, 967, 29 +2, 147, 483, 647 4, 294, 967, 295 9
������ (struct) • ��������� struct My. Struct { short a; char b[4]; }; int main() { struct My. Struct m; m. a = 3; m. b[0] = 4; m. b[2] = 5; : } ตำแหนง : 0020 0021 0022 0023 คา 0024 0025 0026 : 2 3 30 0 211 4 5 5 8 23 33 0027 : 12 : m m. a m. b 21
������ • ��� typedef ��������� struct My. Struct typedef struct { ��������� struct short a; Ø short a; char b[4]; }; typedef struct My. Struct int main() { My. Struct m; : } { char b[4]; } My. Struct; int main() { My. Struct m; : } 22
������ typedef struct { short a; char b[4]; } My. Struct; int main() { My. Struct m; My. Struct *p = &m; (*p). a = 5; // หรอ p->a = 5 p->b[1] = 4; // หรอ (*p). b[1] = 4 } ตำแหนง : คา : 0020 0021 0022 0023 0024 5 2 0 30 211 5 4 8 0025 0026 0027 23 33 20 12 0 0028 0029 2 7 m p 23
%format �� scanf ��� printf %format ���������� �� int %d long %ld long ����� unsigned int unsigned long float ����� double char ����� char array[] %lld %u %llu %f %lf %c %s 28
������ scanf char name[20]; int age; printf("Enter your name and age: "); scanf("%s %d", name, &age); printf("Hello %s. name, age); ผลลพธ You are %d years old. n", : Enter your name and age: Tony 38 Hello Tony. You are 38 years old. 29
������ AND, OR, NOT • & - ������ AND uint 8_t a = 0 b 01001011; uint 8_t b = 0 b 01111000; uint 8_t c = a & b; 0 1 0 1 1 AND 0 1 1 0 0 0 -------0 1 0 0 0 • | - ������ OR uint 8_t a = 0 b 01001011; uint 8_t b = 0 b 01111000; uint 8_t c = a | b; 0 1 0 1 1 OR 0 1 1 0 0 0 -------0 1 1 • ~ - ������ NOT uint 8_t a = 0 b 01001011; uint 8_t b = ~a; NOT 0 1 0 1 1 -------1 0 1 0 0 31
����� if Flowchart C Syntax if (condition) { statement 1; : statement. N; } START condition false true Statement • ������� condition Statement ��������� �� int • ����� {} ��� END condition ���� (������ ( • ��������� 39
����� if…else Flowchart C Syntax START true condition false Statementt 1 Statementf 1 Statementt 2 Statementf 2 END if (condition) { statementt 1; statementt 2; } else { statementf 1; statementf 2; } 40
����� if ������ if (x==1) x==1 true Action 1; false x==2 true Action 2; false x==3 true Action 3; false x==4 true false Default_Action; Action 4; Action 1; else if (x==2) Action 2; else if (x==3) Action 3; else if (x==4) Action 4; else Default_Action; 41
����� switch-case x==1 true Action 1; false x==2 true Action 2; false x==3 true Action 3; false x==4 true false Default_Action; Action 4; switch (x) { case 1: Action 1; break; case 2: Action 2; break; case 3: Action 3; break; case 4: Action 4; break; default: Default_Action; break; } 42
����� while (condition) { stmt 1; stmt 2; : stmt. N; } • ����� stmt 1 ��� stmt. N ������ condition ���� START condition false true Statement END 43
����� do…while ��� do { START stmt 1; stmt 2; : stmt. N; } while (condition); Statement 1 Statement. N • ���� stmt 1. . . stmt. N true condition �������false ����� condition �������END • ������� stmt 1. . . stmt. N 44
����� for ��� • ���������� for (init_stmt; condition; update_stmt) { statement 1; statement 2; : statement. N; } • ���� 1. ���� init_stmt �����. 2��� condition �������� statement 1. . . statement. N 3. ���� update_stmt 46
������ for ��� START init_stmt for (init_stmt; condition; update_stmt) { statement 1; statement 2; : statement. N; } condition false true Statement 1 Statement. N update_stmt END 47
������ ������������ � ������� /�stdio. h scanf, printf, gets, puts ������� math. h sin, cos, exp, pow ����� isalpha, isdigit, ������� ctype. h islower, isupper ������������� strlen, strcpy, string. h strcmp � stdlib. h rand, atoi, atof ���� � 50
������� int incr(int i) { int j; j = i + 1; return j; } int main() { int k, m = 4; k = incr(m); printf ("k = %d, m = %dn", k, m); return 0; } 52
������ �� #include <stdio. h> int main () { char s[10]; printf("Enter password: "); scanf("%s", s); if (s == "pass") puts("Correct password"); else puts("Incorrect password"); ใช == เปรยบเทยบสตรงไมได ใชฟงกชน แทน strcmp() return 0; } 54
- Atmel instruction set
- Atmega 328u
- Dac programming
- Atmega nedir
- Avr sleep
- Atmel atmega
- Atmega
- Dowelltech
- Fuse bits
- Atmega
- Mcu física
- Shadbsr
- Mcu 5
- T=2πr/v
- Aceleración angular
- Batteryless mcu
- Mapa mental movimento circular
- Mcu
- Mcu
- Wide shot camera
- Wcacs
- Velocidade angular formula
- 10 types of camera
- Mcu
- Microcontroller components
- Arduino utasításkészlet
- Mcu
- Mcu nedir
- Ic we
- Elite 6000
- Mcu
- Magnitudes vectoriales
- Vitesse angulaire vitesse linéaire
- Extreme wide shot (ews)
- Mcu flowchart
- Mcu
- Que es mcu
- Mcu edu tw
- Movimiento circular uniforme variado formulas
- Aceleración normal
- Mcu
- Mcu microcontroller unit
- 192,168,0,202
- Genghis khan 168-0
- 192-168-1-1
- Cse 168
- Berapa banyak ip yang dapat digunakan pada 20-bit subnet
- //192/168/105
- Cse
- Ipx-168
- Nat ten
- Classless css
- 192-168-178-22
- 192-168-20-1
- Tupeb