ðçµã¿èŸŒã¿ã·ã¹ãã ãŸãšã
Embeded System, ç¹å®ã®æ©èœãå®çŸããããã«æ©æ¢°ãæ©åšã«çµã¿èŸŒãŸããã³ã³ãã¥ãŒã¿ã·ã¹ãã .
æ§æèŠçŽ
çµã¿èŸŒã¿ã·ã¹ãã ã®äž»ãªæ§æèŠçŽ ã¯ä»¥äž.
- Embedded Systems
- MicroCotroller
- Memory
- RAM
- ROM
- Processor (CPU)
- I/O Ports
- DAC
- Bas
- Timer
- Memory
- External Circuits
- Physical Device
- Sensor
- ADC
- MicroCotroller
ç¹åŸŽ
- A microcontroller hidden inside
- A dedicated purpose
- Run in real time
- Input/output is important
- High volume, low cost
- Extremely reliable
- Low power
- Small size and weight
ð»ãã¡ãŒã ãŠã§ã¢
ãšãã«çµã¿èŸŒã¿éçºã§äœ¿ãããçšèª. ããŒããŠã§ã¢ãšãœãããŠã§ã¢ãã€ãªãéšå.
MicroController
ãã€ã¯ãã³ã³ãããŒã©ãŒ. ãããã, ãã€ã³ã³.
- ðI/O Port
- ðããã€ã¹ãã©ã€ã: set of IO Ports
ðI/O Port
Input Port/Output Port ã®ç¥. Input Port 㯠å€éšã®äžç (å€éšã®éç©åè·¯, sensor, etc)ããã®æ å ±ãã³ã³ãã¥ãŒã¿ã®ãªãã«å ¥ãã. Output Port ã¯ãã®é.
A port is a physical connection between the computer and its outside world.
I/O Address
I/O ããŒãã¢ãã¬ã¹ãšã¯åšèŸºæ©åš (ããã€ã¹) ãš CPU ãããŒã¿ãããåãããéã«äœ¿çšãã 16 ãããã®ã¢ãã¬ã¹.
Linux ã§ã¯, 以äžã§ç¢ºèª.
ls /proc/ioports
GPIO
GPIO 㯠General Purpose Input/Output (æ±çšå ¥åºå) ã®ç¥èª.
LSI ããããé»åæ©åšã®åããå ¥åºå端åã®äžçš®ã§èšå®æ¬¡ç¬¬ã§æ§ã ãªçšéã«å©çšã§ãããã®.
ãœãããŠã§ã¢ã®æ瀺ã«ãã£ãŠä»»æã®å ¥åãããã¯åºåã«å©çšããããšãã§ãã.è€æ°ã®ç«¯åã GPIO ã«å²ãåœãŠãããŠããå Žåã«ã¯, ãããäžã€ã®ã°ã«ãŒããšããŠäžæ¬ããŠå¶åŸ¡ããããšãã§ããGPIO ããŒãããªã©ãšåŒã°ãã
GPIO ãšã¯ ã General Purpose Input/Output ã - æå³/ 解説/ 説æ/ å®çŸ© : IT çšèªèŸå ž
Pin 㯠GPIO ã®æ§æèŠçŽ . ããšãã°, GPIO PortA ã¯, PA0-PA7 ã® 8 ã€ã® Pin ããã§ããŠãã.
Pins can be configured for digital I/O, analog input, timer I/O, or serial I/O. For example PA0 can be digital I/O or serial input.
Pin ã®ãããããå€éšããã€ã¹ã«æ¥ç¶ããã. çšéã¯, ã¬ãžã¹ã¿ã®èšå®ã«ãã£ãŠèªç±ã«ã§ãã.
- PA1 ⊠LED ãžã® Output çš
- PA2 ⊠Switch ããã® Input çš
- PA3 ⊠UART ã® Input çš
- PA4 ⊠UART ã® Output çš
ðããã€ã¹ãã©ã€ã
ããã€ã¹ãã©ã€ã, ç¥ããŠãããã©, ãã©ã€ããŒ. device driver.
- a set of software functions that facilitate the use of an I/O port.
- ã³ã³ãã¥ãŒã¿ããã€ã¹(åšèŸºæ©åš)ãðOSãå¶åŸ¡ããããã®ãœãããŠã§ã¢,
ðããŒããŠã§ã¢ã€ã³ã¿ãã§ãŒã¹
ããŒããŠã§ã¢ãšãœãããŠã§ã¢ãçµã¶ãã®.
interface is defined as the hardware and software that combine to allow the computer to communicate with the external hardware.
ðI/O Port, å€éšé»ååè·¯, ç©ççããã€ã¹, ãœãããŠã§ã¢ãªã©ãéãããã®.
An interface is defined as the collection of the I/O port, external electronics, physical devices, and the software, which combine to allow the computer to communicate with the external world.
以äžã® 4 ã€ã«åé¡ããã.
- Parallel - binary data are available simultaneously on a group of lines
- Serial - binary data are available one bit at a time on a single line
- Analog - data are encoded as an electrical voltage, current, or power
- Time - data are encoded as a period, frequency, pulse width, or phase shift
Parallel Interface
ãã©ã¬ã«ããŒããšã¯, ã³ã³ãã¥ãŒã¿ã·ã¹ãã å ã§, ã°ãã°ãã®åšèŸºæ©åšãã±ãŒãã«ã§æ¥ç¶ããããã«äœ¿ãããç©ççãªã€ã³ã¿ãã§ãŒã¹ã®äžçš®.
- ãã©ã¬ã«ããŒã - Wikipedia
- ãã©ã¬ã«ã€ã³ã¿ãŒãã§ãŒã¹ãšã¯ ããã©ã¬ã«ã€ã³ã¿ãã§ãŒã¹ã (parallel interface): - IT çšèªèŸå žãã€ããª
PCI
ã³ã³ãã¥ãŒã¿ã®ããã»ããµãšåšèŸºæ©åšãšã®éã®éä¿¡ãè¡ãããã®ãã¹ã¢ãŒããã¯ãã£ã®äžã€.
USB
USB (Universal Serial Bus) ã¯ããããã©ã°ã«å¯Ÿå¿ããã€ã³ã¿ãŒãã§ã€ã¹ã®èŠæ Œã§ã. USB ããã€ã¹ã¯ USB ã³ã³ãããŒã© (ããã) ã«ãã£ãŠå¶åŸ¡ãããŸã. ãŸã, ããããã® USB ã³ã³ãããŒã©ã«ã¯ã¢ãžã¥ãŒã« (ããã€ã¹ãã©ã€ã) ãå¿ èŠã§ã.
以äžã¯äž»ãª USB ã³ã³ãããŒã©, USB ã®èŠæ Œ, ã¢ãžã¥ãŒã«ããŸãšãããã®ã§ã.
Controller | Spec | USB mod (2.4) | USB mod (2.6) |
---|---|---|---|
UHCI | USB1.1 | usb-uhci | uhci_hcd |
OHCI | USB1.1 | usb-uhci | uhci_hcd |
EHCI | USB2.0 | - | ehci_hcd |
USB ã«ã¯ä»¥äžã®ãããªç¹åŸŽããããŸã.
- USB ã³ã³ãããŒã©ã¯æ倧 127 å°ã® USB ããã€ã¹ãå¶åŸ¡ã§ãã
- ã·ã¹ãã ãèµ·åããŠããç¶æ ã§ã USB ããã€ã¹ã®å·®ãæ¿ããåºæ¥ã (ããããã©ã°)
- æ¥ç¶ããŠãããã¹ãããé»æºãäŸçµŠã§ãã
- ããŒããŒã, ããŠã¹, ããªã³ã¿ãªã©å€ãã®ããã€ã¹ã USB ã«å¯Ÿå¿ããŠãã
ãªã, USB1.1 èŠæ Œã¯ã«ãŒãã« 2.4 ãã, USB2.0 èŠæ Œã¯ã«ãŒãã« 2.6 ãããµããŒããããŠããŸã.
Syncronization
ããŒããŠã§ã¢ãšãœãããŠã§ã¢ã®åæåŠç.
ããŒããŠã§ã¢ã®ã¹ããŒããšãœãããŠã§ã¢ã®ã¹ããŒãã¯, ãœãããŠã§ã¢ã®æ¹ãæ©ãããçžäºã§ãããšãããããã«ã¯ä»¥äžã®æ段ããã.
Blind-Cycle
決ããããæé Sleep ããããšã« I/O ã¹ããŒã¿ã¹ããã§ãã¯ãã.
the software writes data to the output device, triggers (starts) the device, then waits a specified time. We call this method blind, because there is no status information about the I/O device reported to the software.
Busy-Wait
Input device ã®ããŒã¿ãæŽæ°ããããšãã« I/O ã¹ããŒã¿ã¹ããã§ãã¯ãã.
ç¶æ ã Busy ãªãã° Wait (loop), Ready ãªãã°æ¬¡ã®ã¹ããããž.
Busy Wait is a software loop that checks the I/O status waiting for the done state. For an input device, the software waits until the input device has new data, and then reads it from the input device,
Interrupt
ããŒããŠã§ã¢ãçºçãããç¹å¥ãªéç¥.
An interrupt uses hardware to cause special software execution. With an input device, the hardware will request an interrupt when input device has new data. The software interrupt service will read from the input device and save in global RAM,
Periodic Polling
ã¯ããã¯ã¿ã€ãã®å²ã蟌ã¿å¥æ©ã§ I/O ã®ã¹ããŒã¿ã¹ããã§ãã¯
DMA
Direct Memory Access. ããã¡ã¢ãªããå¥ã®ã¡ã¢ãªã«çŽæ¥æ å ±ãæžã蟌ã. CPU ãä»ããããšãªãã¡ã€ã³ã¡ã¢ãªãšåšèŸºæ©åšã®éã§çŽæ¥çã«æ å ±è»¢éãè¡ãæ¹åŒ.
# ããã€ã¹ã䜿çšäžã® DMA ãã£ãã«ã«é¢ããæ
å ±
# cat /proc/dma
Serial Interface
UART
Universal Asynchronous Receiver/Transmitter (UART). 調æ©åææ¹åŒã«ããã·ãªã¢ã«éä¿¡ãããããã®æ±çš I/F.
æåãªã®ã§, æè¿ã®ã»ãšãã©ã®ãã€ã³ã³ã«æèŒãããŠããããã.
ðABI
ð±ã¢ããªã±ãŒã·ã§ã³ïŒãŠãŒã¶ïŒããã°ã©ã ãšã·ã¹ãã ïŒãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ãã©ã€ãã©ãªïŒãšã®éã®ããã€ããªã¬ãã«ã®ðã€ã³ã¿ãã§ãŒã¹.
Interrupt
Hardware Interrupt Software Action. éåæäŸå€ãšããã. ããã»ããµã®å€éšããã®ã€ãã³ãã«ãã£ãŠã²ãããããã.
- I/O interrupts
- hittng Ctrl-Â-C on the keyboard
- clicking a mouse buVon or tapping a touchscreen
- arrival of a packet from a network
- arrival of data from a disk
- Hard reset interrupt
- hittng the reset buVon on front panel
- Soft reset interrupt
- hittng Ctrl-Â-Alt-Â-Delete on a PC
Busy-Wait ã®å¶åŸ¡ã§åŸ ã£ãŠãããªãå Žåã¯, Interrupt ãå©çšãã.
Edx
ããããã¯, äžè¬çãªèª¬æã§ã¯ãªã㊠edX ã®äžã ãã®å®çŸ©.
Arm/DisArm
- Arm ãšã¯, ããŒããŠã§ã¢ãå²ã蟌ã¿ããããããšãæå¹åãã.
- DisArm ãšã¯, ããŒããŠã§ã¢ãå²ã蟌ã¿ããããããšãç¡å¹åãã.
Enable/Disable
- Enable ã¯äžæçã«å²ã蟌ã¿ãæå¹åãã.
- Disable ã¯äžæçã«å²ã蟌ã¿ãç¡å¹åãã.Disable äžã«çºçãã Interuppt 㯠Pending ãããŠ, Enable æã«éç¥ããã.
Interruput ã®åæååŠç
- Trigger flag set by hardware
- the device is armed by software
- the device is enabled for interrupts in the NVIC
- the processor is enabled for interrupts (PRIMASK I bit is clear)
- the interrupt level must be less than the BASEPRI.
Context Switch
å²ã蟌ã¿ãããŒããŠã§ã¢ãæ€ç¥ãããšãã«, foreground ãš background ã®ã¹ã¬ãããå ¥ãæ¿ãã.
çŸåšã®ããã»ã¹ã®å®è¡ãäžæåæ¢ããŠ, ã¹ã¿ãã¯ã«ã¬ãžã¹ã¿æ å ±ãèŠããŠãã.
å²ã蟌ã¿ãã³ãã©ãå®è¡ããŠ, ãã³ãã©ã®å®è¡ãçµäºãããããšã®ããã»ã¹ãåéãã.
- Current instruction is finished,
- Eight registers are pushed on the stack,
- LR is set to 0xFFFFFFF9,
- IPSR is set to the interrupt number,
- PC is loaded with the interrupt vector
Interrupt Service Routine (ISR)
å²ã蟌ã¿ãµãŒãã¹ã«ãŒãã³. å²ã蟌ã¿ãã³ãã©ãšããã.
ã³ã³ããã¹ãã¹ã€ããã«ãã£ãŠ,foreground ã§åäœããŠãã busy-wait ãªã¹ã¬ãããš ISR ãã¹ã¯ããããã.
å²ã蟌ã¿åãä»ãã«ãã£ãŠèµ·åããããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ãããã€ã¹ãã©ã€ãã®ã³ãŒã«ããã¯ã«ãŒãã³.å²ã蟌ã¿ãã³ãã©ã¯å²ã蟌ã¿åå ã«ãã£ãŠããããååšã,å²ã蟌ã¿ãã³ãã©ããã®ã¿ã¹ã¯ãå®äºãããŸã§ã«ãããæéãæ§ã ã§ãã.
NVIC
å²ã蟌ã¿ãã³ãã©ã«å¯Ÿå¿ããããé¢æ°ã¯, startup script ã«äºåã«ç»é²ããŠãã.
vector ãšããã¡ã¢ãªé åã«ã·ã¹ãã ã«ã©ã®é¢æ°ãå®è¡ããã°ããããã¢ãã¬ã¹ãšããŠæãã.
interrupt çºçæ㯠vector ãåç §ããŠ, ããã«å¯Ÿå¿ããå²ã蟌ã¿ã«ãŒãã³ã®é¢æ°ãåŒã¶.
nested vectored interrupt controller (NVIC) manages interrupts, which are hardware-triggered software functions. Some internal peripherals, like the NVIC communicate directly with the processor via the private peripheral bus (PPB). The tight integration of the processor and interrupt controller provides fast execution of interrupt service routines (ISRs), dramatically reducing the interrupt latency.
Acknowledge
å²ã蟌ã¿ã ISR ãèªèããããš. ISR ãå²ã蟌ã¿ã®èªèãè¡ã£ãåŸ, åãããã€ã¹ããã®å²ã蟌ã¿ãçºçããªãããå²ã蟌ã¿ãã¹ã¯ãããå¿ èŠããã. ããããªããš, ã¯ã©ãã·ã¥ããæãããã.
å®è£ ã§ãã£ãŠã¯ãããªãããšã¯ä»¥äž.
- é·æéã®åŠçã¯ããŠã¯ãããªã.
- åŸ ã¡ç¶æ ã«ãªã£ãŠã¯ãããªã, Delay Loop ã¯ã€ãããªãã»ãããã.
- åŒãã§ã¯ãããªãé¢æ°ããã.
å²ã蟌ã¿ãã³ãã©ã§ã¯å¿ èŠæå°éã®åŠçã®ã¿ãè¡ã, å¥ã®ã¿ã¹ã¯ã«éç¥ããŠ, ã¡ã€ã³ã®åŠçã¯ãã£ã¡ã§ãããããã«å®è£ ãã¹ã.
ISR ããã¡ã€ã³åŠçãžã®éç¥æ¹æ³
ISR ãšã¡ã€ã³åŠçã¯ã°ããŒãã«ãªã¡ã¢ãªé åãä»ããŠæ å ±ãåæž¡ããã.
- Binary Semaphore
ISR 㧠決ãããã flag ãç«ãŠãŠ, ã¡ã€ã³åŠçã§ãã®ãã©ã°ãç£èŠãã. flag ã 1 ãªãã°, ããã®ãã©ã°ã«å¯Ÿå¿ããåŠçãå®æœãã.
- MailBox
flag ãšãšãã«ããŒã¿ãæž¡ãããšããã.
flag ã Status ãšãã, flag ãš data ãåãããããŒã¿æ§é ã Mail ãšãã. (MailBox Pruducer-Consumer Pattern)
- FIFO queue
ISR 㧠Fifo ãªã¡ã¢ãªé åã«ããŒã¿ã PUT ã, ã¡ã€ã³åŠçã® loop åŠçã§ã§å®æçã« Fifo 㪠data ããã§ãã¯ã, é 次å®è¡ãã.
DAC
digital to analog converter (DAC).
ããžã¿ã«é»æ°ä¿¡å·ãã¢ããã°é»æ°ä¿¡å·ã«å€æããé»ååè·¯.
ããžã¿ã«-ã¢ããã°å€æåè·¯ - Wikipedia
Sound
ADC
analog to digital converter (ADC).
ã¢ããã°é»æ°ä¿¡å·ãããžã¿ã«é»æ°ä¿¡å·ã«å€æããé»ååè·¯.
ã¢ããã°-ããžã¿ã«å€æåè·¯ - Wikipedia
Sensor
ðã³ã³ãã¥ãŒã¿ã·ã¹ãã ã®çè«ãšå®è£ (From NAND To Tetris)
- From Nand to Tetris
- https://www.nand2tetris.org/
- â«é¡å€åœ¢çã®å€ç§æè¡ãæ±æµ·å€§åŠç é¢ã§åãã(2015/04)ã®ãšãã«æã ã£ãã®ã§èªãã§ã.
- ããŒããŠã§ã¢ã®ä»çµã¿ãåŠã¶ïŒcoursera 㧠From Nand To Tetris Part1 ãåãã | Futurismo
week0
week1: ã²ãŒããž
è«çã²ãŒã
- And
- Or
- Xor
- Not
- Not16, And16, Or16, Mux16 ⊠16 é²æ°ã® è«çã²ãŒã
ãã«ããã¬ã¯ãµ
- Mux ⊠ãã«ããã¬ã¯ãµ
- DMux ⊠ããã«ããã¬ã¯ãµ
- Mux8Way16, DMux8Way, DMux4Way .. 16 é²æ°ã®ãã«ããã¬ã¯ãµ
week2: CPU ãž
ç®è¡ã²ãŒã
-
HalfAdder ⊠åå ç®åš
-
FullAdder âŠ å šå ç®åš
-
Add16 ⊠16 é²å ç®
-
Inc16 ⊠16 é²ã€ã³ã¯ãªã¡ã³ã¿
ALU
- ALU ⊠è«çç®è¡ã²ãŒã
week3: Memory ãž
Memory
- Bit, Register ⊠ã¬ãžã¹ã¿
- RAM8, RAM16, RAM64, RAM512, RAM4K, RAM16K ⊠RAM
Counter
- PC ⊠ããã°ã©ã ã«ãŠã³ã¿