G2IK9


    Uraani lõhustumise tulemusena, peale baariumi saadakse veel
    krüptooni. See on väga lihtne: uraani järjenumber on 92,
    baariumi 56, siis jääb 36, õige? See ongi krüptoon*1 ..

    Sihi valik 1975 s1e2, 54:28

STK500 ja ATmega8
=================

pinout
------

            ---
PORTB  PB0 |1 2| PB1                       ATMEGA8
       PB2 |3 4| PB3                       ---v---
       PB4 |5 6| PB5          (RESET) PC6 | 1   28| PC5 (ADC5/SCL)
       PB6 |7 8| PB7            (RXD) PD0 | 2   27| PC4 (ADC4/SDA)
       GND |9 A| VTG            (TXD) PD1 | 3   26| PC3 (ADC3)
            ---                (INT0) PD2 | 4   25| PC2 (ADC2)
            ---                (INT1) PD3 | 5   24| PC1 (ADC1)
PORTE  PE0 |1 2| PE1         (XCK/T0) PD4 | 6   23| PC0 (ADC0)
       PE2 |3 4| RST                  VCC | 7   22| GND
       REF |5 6| GND                  GND | 8   21| AREF
       XT1 |7 8| XT2    (XTAL1/TOSC1) PB6 | 9   20| AVCC
       GND |9 A| VTG    (XTAL2/TOSC2) PB7 |10   19| PB5 (SCK)
            ---                  (T1) PD5 |11   18| PB4 (MISO)
            ---                (AIN0) PD6 |12   17| PB3 (MOSI/OC2)
LEDS  LED0 |1 2| LED1          (AIN1) PD7 |13   16| PB2 (SS/OC1B)
      LED2 |3 4| LED3          (ICP1) PB0 |14   15| PB1 (OC1A)
      LED4 |5 6| LED5                      -------
      LED6 |7 8| LED7
      GND  |9 A| VTG
            ---

Ühendamine (STK500)
-------------------
                                        \\   150R
          PA0 <-> NC    LEDn o---     --|<|--/\/\/---o +5V
          PA1 <-> NC             \   /
          PA2 <-> NC              v /
          PA3 <-> NC              ---
          PA4 <-> NC               |  10K
          PA5 <-> NC                --/\/\/---o VTG
          PA6 <-> NC
          PA7 <-> NC             ---
          GND <-> NC       LED0 |1 2| LED1
          VTG <-> NC       LED2 |3 4| LED3
                           LED4 |5 6| LED5
          PD0 <-> HEX0     LED6 |7 8| LED7
          PD1 <-> HEX1     GND  |9 A| VTG
          PD2 <-> HEX2           ---
          PD3 <-> HEX3
          PD4 <-> HEX4   SWn o--/\/\/--+--/\/\/--o VTG
          PD5 <-> HEX5                 |
          PD6 <-> HEX6               | o
          PD7 <-> HEX7               | o
          GND <-> HGND                 |
          VTG <-> HANODE              ---

          PE0 <-> NC             ---
          PE1 <-> NC        SW0 |1 2| SW1
          PE2 <-> NC        SW2 |3 4| SW3
          RST <-> NC        SW4 |5 6| SW5
          REF <-> NC        SW6 |7 8| SW7
          GND <-> NC        GND |9 A| VTG
      R > XT1 <-> LED6           ---
      B > XT2 <-> LED7
          GND <-> NC
          VTG <-> NC

   GREY > PB0 <-> LED0
  BLACK > PB1 <-> LED1
      G > PB2 <-> LED2
      Y > PB3 <-> LED3
      B > PB4 <-> LED4
      W > PB5 <-> LED5
      R > XT1 <-> LED6
  BLACK > XT2 <-> LED7
          GND <-> NC
          VTG <-> NC

   GREY > LED0 <-> PB0
  BLACK > LED1 <-> PB1
      G < LED2 <-> PB2
      Y < LED3 <-> PB3
      B < LED4 <-> PB4
      W < LED5 <-> PB5
      R < LED6 <-> PB6
  BLACK < LED7 <-> PB7
          GND  <-> NC
          VTG  <-> NC

NAND elemendi baasil ehitatud trigerite simuleerimine VMLab-is
==============================================================

Sünkroonne D-triger "algseis/töö" nupuga -- VMLab.

  ; Click K2 to unlock inputs (button K2 forces necessary
  ; initial state to prevent model's self-excitation)
  ; Set Data with K0 (can be 0 or 1)
  ; Save Data with Clock pulse (010)

  K0  VSS V16 LATCHED ; DATA
  R1  VDD V16 1K
  K1  VSS V23 LATCHED ; CLOCK
  R2  VDD V23 1K
  K2  VSS VK2 LATCHED ; INITIAL STATE/WORK
  R3  VDD VK2 1K
  XK2 ND2 VK2 VK2 V20
  X6D ND2 V16 V20 V14
  X5D ND2 V20 V23 V10
  X7A ND2 V14 V14 V18
  D3  VDD V18
  X4A ND2 V14 V14 V27
  X7B ND2 V10 V10 V12
  D4  VDD V12
  X1C ND2 V14 V10 V29
  X1B ND2 V27 V10 V28
  X1D ND2 V29 V30 V3
  X2A ND2 V28 V3  V30
  X4B ND2 V3  V3  V8
  D1  VDD V8
  X3A ND2 V30 V30 V5
  D2  VDD V5

  .PLOT V(V16) V(VK2) V(V20) V(V14) V(V23) V(V10)

Püsivara (HEX faili) kõrvetamine*2 virtuaalmasinas
==================================================

Kasutatud riistvara: STK-500 programmaator
                     AVR chip ATmega8
                     Juhe USB-RS232-DB9 Prolific (PL2303)

XPA VM allalaadida Ser2Pl.dll

  http://www.sysfiledown.com/article/ser2pl.sys.shtml

Installida host arvutisse:

  VirtualBox 5.14 laienduspakett

Virtuaalmasinasse:

  AVR Studio 4.18SP3.
  VMLab-3.15
  WinAVR C 2010 (C:\WinAVR kausta)

Lisada jadaport:

    XPA Settings, Serial Ports, Port 1
      [v] Enable COM1 IRQ4 0x378 Disconnected
        [v] Connect to existing pipe/socket

AVR Studio:

  Tools -> Program AVR -> Autoconnect..

Näide. ATmega8 püsivara -- Loendurid.

  #include <avr/io.h>
  #include <util/delay.h>

  int main(void) {
    int i = 0;
    DDRD = 0xff;
    while(1) {
      _delay_ms(500);
      PORTD =  ((i / 10) << 4) | (i % 10);
      i++; i = (i > 99) ? 0 : i;
    }
  }

Sõelumise peensused
===================

Oluline: 1. Lubatud tehingute tabel
         2. Prioriteetide tabel
         3. Sõelumise suund*3 (vasakult-paremale, paremalt vasakule)

---------------

*1) Aatomnumber

  https://et.wikipedia.org/wiki/Aatomnumber

Keemilise elemendi aatomnumber ehk järjenumber ehk laenguarv (Z) on prootonite arv selle elemendi aatomi tuumas.

*2) Küll aga saab Cubietruckile kõrvetada püsivara..

  http://lauri.võsandi.com/cfgmgmt/trusty-ltsp-ja-id-kaart.html

*3) Assotsiatiivsus: Tehinguid tavaliselt töödeldakse vasakult paremale. See tähendab, et tehingud võrdse prioriteediga saavad töödeldud järjekorras vasakult paremale. Näiteks 2 + 3 + 4 töödeldakse kui (2 + 3) + 4. Mõned tehingud, nagu näiteks omistamisoperaator omab paremalt-vasakule assotsiatiivsust, see tähendab, et a = b = c vaadeldakse kui a = (b = c). http://wombat.org.ua/AByteOfPython/operators_and_expressions.html

C
-

  #include <stdio.h>

  int left() { printf("%c", 'L'); return 1; }
  int mid() { printf("%c", 'M'); return 2; }
  int right() { printf("%c", 'R'); return 3; }
  void twoargs( int ax, int ay) { printf("%d-%d ", ax, ay); }
  void foo( int ax, int ay, int az) { printf("\n"); }

  int main() {
    int dummy = left() + mid() + right();
    printf("\n");

    foo( left(), mid(), right());

    // Remove redundant code:)
    int x = 0;
    while ( x < 8) twoargs( x+++0., x+0.);

    return 0;
  }

Trükib:

  LMR
  RML
  0-0 1-1 2-2 3-3 4-4 5-5 6-6 7-7

C++
---

  #include <iostream>

  using namespace std;

  int left() { cout << 'L'; return 1; }
  int mid() { cout << 'M'; return 2; }
  int right() { cout << 'R'; return 3; }
  void twoargs( int ax, int ay) { cout << ax << '-' << ay << ' '; }
  void foo( int ax, int ay, int az) { cout << endl; }

  int main() {
    int dummy = left() + mid() + right();
    cout << endl;

    foo( left(), mid(), right());

    // Remove redundant code:)
    int x = 0;
    while ( x < 8) twoargs( x+++0., x+0. );

    return 0;
  }

Trükib:

  LMR
  RML
  0-0 1-1 2-2 3-3 4-4 5-5 6-6 7-7

C#
---

  using System;

  namespace parse {
      class Program {
          static int left() { Console.Write("L"); return 1; }
          static int mid() { Console.Write("M"); return 2; }
          static int right() { Console.Write("R"); return 3; }
          static void twoargs( int ax, int ay) { Console.Write("{0}-{1} ", ax, ay); }
          static void foo( int ax, int ay, int az) { Console.WriteLine(""); }

          static void Main() {
              int dummy = left() + mid() + right();
              Console.WriteLine("");

              foo( left(), mid(), right());

              int x = 0;
              while ( x < 8) twoargs( x, x++);
              Console.ReadKey();
          }
      }
  }

Trükib:

  LMR
  LMR
  0-0 1-1 2-2 3-3 4-4 5-5 6-6 7-7

Java
----

  public class Hello {
      static int left () { System.out.print("L"); return 1; }
      static int mid () { System.out.print("M"); return 2; }
      static int right () { System.out.print("R"); return 3; }
      static void twoargs( int ax, int ay) { System.out.format("%d-%d ", ax, ay); }
      static void foo( int ax, int ay, int az) { System.out.format("%n"); }

      public static void main(String[] args) {
          int dummy = left() + mid() + right();
          System.out.format("%n");
          foo( left(), mid(), right());
          int x = 0;
          while ( x < 8) twoargs( x, x++);
          System.out.format("%n");
      }
  }

Trükib:

  LMR
  LMR
  0-0 1-1 2-2 3-3 4-4 5-5 6-6 7-7

Python 2.x
----------

  def left():
      print("L"),
      return 1

  def mid():
      print("M"),
      return 2

  def right():
      print("R"),
      return 3

  def twoargs( ax, ay):
      print( str(ax) + "-" + str(ay)),

  def foo( ax, ay, az):
      print("")

  dummy = left() + mid() + right()
  print("")

  foo( left(), mid(), right())

  x = 0
  while x < 8:
      twoargs( x, x)
      x = x + 1

Trükib:

  L M R
  L M R
  0-0 1-1 2-2 3-3 4-4 5-5 6-6 7-7

