Shiekh El-Embedded

Shiekh El-Embedded

Share

Shiekh El-Embedded

29/11/2024

๐–๐ก๐š๐ญ ๐ข๐ฌ ๐ญ๐ก๐ž ๐›๐ฎ๐ข๐ฅ๐ ๐ฉ๐ซ๐จ๐œ๐ž๐ฌ๐ฌ? ๐‡๐จ๐ฐ ๐ข๐ฌ ๐ข๐ญ ๐๐จ๐ง๐ž ? ๐ฐ๐ก๐š๐ญ ๐ข๐ฌ ๐ญ๐ก๐ž ๐œ๐จ๐ฆ๐ฉ๐ข๐ฅ๐ž๐ซ ๐ฌ๐ญ๐š๐ ๐ž๐ฌ ? ๐–๐ก๐š๐ญ ๐š๐ซ๐ž ๐ฆ๐ž๐ฆ๐จ๐ซ๐ฒ ๐ฌ๐ž๐œ๐ญ๐ข๐จ๐ง๐ฌ? ๐–๐ก๐š๐ญ ๐ข๐ฌ ๐ญ๐ก๐ž ๐ฌ๐ฒ๐ฆ๐›๐จ๐ฅ ๐ญ๐š๐›๐ฅ๐ž? ๐–๐ก๐š๐ญ ๐ข๐ฌ ๐ญ๐ก๐ž ๐๐ž๐›๐ฎ๐  ๐ข๐ง๐Ÿ๐จ ?

--ุชุนุฑู ุงู† ุงู„ู†ู‡ุงุฑุฏู‡ ู‡ู†ุชูƒู„ู… ููŠ ู…ูˆุงู„ ุทูˆูŠู„ ูˆุนุฑูŠุถ ุญุฑููŠุง ู‡ูˆ ุงู„ูุชุฑุฉ ุงู„ุฒู…ู†ูŠุฉ ุจูŠู† ุงู†ูƒ ุชุฏูˆุณ ุนู„ูŠ ุฒุฑุงุฑ ุงู„ build ููŠ ุงู„ ide ูˆุจูŠู† ู„ู…ุง ุชุฑูุน ุงูŠุฏูƒ ู…ู† ุนู„ูŠ ุงู„ุฒุฑุงุฑ ุฌุฒุก ู…ู† ู…ูŠูƒุฑูˆ ุซุงู†ูŠุฉ ูุนู„ุง ุจุณ ููŠู‡ ูƒู…ูŠุฉ ุญูƒุงูŠุงุช ูŠุงุงุงุงุงุงู‡ ุชุนุงู„ูŠ ูŠุง ุญุณู† ู† deep dive ููŠู‡ุง ูˆู†ูู‡ู… ูƒู„ ุญุชู‡ ู„ูŠู‡ ูˆุจุชุนู…ู„ ุงูŠู‡ ูˆุงุฐุงูŠ !

--ู‚ูˆู„ูŠ ุจุณ ูƒุฏุง ู‡ูˆ ูŠุนู†ูŠ ุงู„ build process ุŸ ูˆุจุชู… ุงุฐุงูŠ ุŸ
ูˆุงูŠู‡ ู„ุงุฒู…ุชู‡ุง ูˆุจุชุชู‚ุณู… ู„ูƒุงู… Stage ุŸ ูˆูƒู„ stage ููŠู‡ุง ุงูŠู‡ ูˆู„ูŠู‡ ูˆุจุชุนู…ู„ ุงูŠู‡ ุŸ
ูˆูŠุนู†ูŠ ุงูŠู‡ ุง generate ุงู„ binary code ุŸ
ูˆุงูŠู‡ ู‡ูˆ ุงู„ Compiler ูˆุจูŠุญุตู„ ููŠู‡ ุงูŠู‡ ุŸ ูˆุจูŠุชู‚ุณู… ู„ูƒุงู… stage ุŸ
ูˆุงุฐุงูŠ ุงู„ููŠู„ุงุช ุงู„ูƒุชูŠุฑ ุงู„ู„ูŠ ุงู†ุง ูƒุงุชุจู‡ุง ููŠ ุงู„ุจุฑูˆุฌูŠูƒุช ุฏูŠ ุจุชุชุฌู…ุน ู…ุน ุจุนุถู‡ุง ุนุดุงู† ูŠุทู„ุน ู„ูŠุง executable file ุงุฎุฏู‡ ุงุญุฑู‚ู‡ ุนู„ูŠ ุงู„ุจูˆุฑุฏู‡ ุŸ
--ูˆูŠุนู†ูŠ ุงูŠู‡ symbol table ูˆุจุณุชุฎุฏู…ู‡ ููŠ ุงูŠู‡ ุŸ
ูˆุงุฐุงูŠ ู„ูˆ ูุงูŠู„ ุจูŠุทู„ุจ function ู…ูˆุฌูˆุฏู‡ ููŠ File ุชุงู†ูŠ ุงุฐุงูŠ ุงู„ linker ุจูŠูˆูู‚ ุงู„ุฑุฃุณูŠู† ุฏูˆู„ ููŠ ุงู„ุญู„ุงู„ ุŸ
ูŠุนู†ูŠ ุจูŠุนุฑู ู…ู†ูŠู† ุงู† function ุงู„ู„ู‰ ุงู†ุช ุจุชุทู„ุจู‡ุง ุฏูŠ ู…ูˆุฌูˆุฏ ููŠ ูุงูŠู„ ูƒุฐุง ูˆุงู„ Definition ุจุชุงุนู‡ุง ุงู‡ูˆ ุŸ
ูˆ ู‡ูŠููŠุฏูƒ ุจุงูŠู‡ ูู‡ู… ุงู„ build ุจุฑูˆุณูŠุณ ุงู†ุช ุจุชู‚ูˆู„ูŠ ููŠ ุงู„ุงูˆู„ ูˆุงู„ุงุฎุฑ ุงู†ุง ู„ูˆ ุดุบุงู„ ุนู„ูŠ ุงู„ ide ุจุถุบุท ุนู„ูŠ ุงู„ build button ูˆุฎู„ุตุช ุŸ
--ูˆูŠุนู†ูŠ ุงูŠู‡ Debug info ุŸ ูˆุจุงุณุชุฎุฏู…ู‡ุง ููŠ ุงูŠู‡ ุŸ ูˆูŠุญุตู„ ุงูŠู‡ ู„ูˆ ุทู„ุนุช ุงู„ binary ู…ู† ุบูŠุฑู‡ุง ุŸ

--ุญุงุถุฑ ูŠุง ุญุณู† ู‡ุฌุงูˆุจูƒ ุนู„ูŠ ูƒู„ ุฏู‡ ูˆุฒูŠุงุฏุฉ โ€ฆ.ุฏุง ุงุญู†ุง ุนู†ูŠู†ุง ูˆุงู„ู„ู‡ (ุฏุงู†ุง ุญุชูŠ ูŠุง ุญุณู† ู‡ู…ุดูŠ ุงู„ุฌูŠุด ูƒู…ุงู† ุดู‡ุฑ ุงู„ุง ูƒุงู… ูŠูˆู… ูˆู„ุง ู‡ุชู„ุงู‚ูŠ ุญุฏ ุชู‚ูˆู„ู‡ ู…ุด ูุงู‡ู… ูˆู„ุง ู…ุนู„ุด ูˆุถุญู„ูŠ ู…ุนู„ุด ุจู‚ู‰ ูŠุง ุญุณู† ู‡ุฑูˆุญ ุงุฎุฏู… ุชุฑุงุจ ุงู„ูˆุทู† ูˆู‡ุจู‚ูŠ ุงุฑุฌุนู„ูƒ ููŠ ุงู„ุงุฌุงุฒุงุช ูˆุงุจู‚ูŠ ุงุฏุนูŠู„ูŠ ุจู‚ู‰ ูŠุง ุญุณู† ุงู„ุณู†ู‡ ุชูƒูˆู† ู‡ูŠู†ู‡ ุนู„ูŠุง ูˆุชุนุฏูŠ ุจุณุฑุนู‡)โค๏ธ


/*************************/

๐Ÿ-๐–๐ก๐š๐ญ ๐ข๐ฌ ๐ญ๐ก๐ž ๐›๐ฎ๐ข๐ฅ๐ ๐ฉ๐ซ๐จ๐œ๐ž๐ฌ๐ฌ?

--Getting target executable code from c files.
--ุงู„ build process ุงูˆ ุงู„ compilation process ุฏูŠ ุงู„ุนู…ู„ูŠู‡ ุงู„ู„ู‰ ุจู†ุนู…ู„ู‡ุง ุนุดุงู† ุงู„ .c ุงู„ู„ู‰ ู…ุนุงู†ุง ุฏู‡ ูŠุชุญูˆู„ ู„ .o ุงูˆbin ุนุดุงู† ู†ุงุฎุฐู‡ ู†ุนู…ู„ู‡ burn ุนู„ูŠ ุงู„ microcontroller.
--ุนุงูŠุฒูŠู† ู†ูู‡ู… ุจู‚ู‰ ู…ู† ุงูˆู„ ู…ูŠูƒูˆู† ุงู„ file.c ู…ุนุงูŠุง ู„ุญุฏ ู…ุทู„ุน file.o ุงุฎุฏู‡ ุงุญุทู‡ ุนู„ูŠ ุงู„ microcontroller.
--ูู‡ู…ูƒ ู„ู„ build process ุฏุง ุจูŠู‚ูˆูŠูƒ ููŠ ุงู† ุชู‚ุฏุฑ ุชู‚ูุด ุงูˆ ุชุญุฏุฏ ุงู„ error ุงู„ู„ู‰ ุทุงู„ุน ู„ูŠูƒ ุฏู‡ ุจุณุจุจ ุงูŠู‡ ุฃูˆ ูŠู‚ุน ููŠ ุงู†ูŠ stage ูˆูƒู…ุงู† ู‡ูŠุนุฑููƒ ุงู„ statements ู„ุชุญูˆูŠู„ ุงู„ c code ู„ machine language.
--ุจุงู„ุงุถุงูู‡ ูƒู…ุงู† ู‡ุชุนุฑู ุชูƒุชุจ ูƒูˆุฏ ูƒูˆูŠุณ ู„ุงู† ุงู†ุช ุจู‚ูŠุช ุนุงุฑู ุงู„ูƒูˆุฏ ุฏู‡ ุจูŠุฑูู„ูŠูƒุช ุงุฐุงูŠ ููŠ ุงู„ู…ูŠู…ูˆุฑูŠ ูˆุนู„ูŠ ุงู„ู‡ุงุฑุฏูˆูŠุฑ ุจุชุงุนูƒ .
--ุงุฐูƒุฑูƒ ุจุญุงุฌู‡ ุงุญู†ุง ุจู†ุดุชุบู„ ุนู„ูŠ 2 macin ุงู„ develop ุฃูˆ ุงู„ host machine ูˆุฏู‡ ุงู„ู„ุงุจุชูˆุจ ุจุชุงุนู†ุง ูˆุฏู‡ ุงู„ู„ู‰ ุจูŠุชู… ุนู„ูŠู‡ ุงู„ build process ูˆููŠู‡ ุงู„ target machine ูˆุฏู‡ ุงู„ microcontroller ุจุชุงุนู†ุง ุงู„ู„ู‰ ู‡ู†ุฑูˆุญ ู† buran ุนู„ูŠู‡ ุงู„ูƒูˆุฏ ุจุชุงุนู†ุง.

/******************/

-- ุงู„ุญุชู‡ ุฏูŠ ู‡ุชูˆุฏูŠู†ุง ู„ุณุคุงู„ ูƒูˆูŠุณ ุงู„ุง ูˆู‡ูˆ ุงูŠู‡ ุงู„ูุฑู‚ ุจูŠู† ุงู„ Natine Toolchain ูˆุงู„ cross Toolchain ุŸ
What is Native Toolchain and Cross Toolchain ?
--ุทุจ ูŠุนู†ูŠ ุงูŠู‡ ุงุตู„ุง ุงู„ Toolchain ุŸ
--ุฏูŠ ูŠุง ุญุณู† ุจูŠูƒูˆู† ููŠู‡ุง ุงู„ compiler + linker + c libres + binary utilites โ€ฆ ุงู„ toolchain ุฏูŠ ุงู„ู„ู‰ ุจุชุนู…ู„ ุจูŠู‡ุง ูƒู„ ุงู„ู…ุฑุงุญู„ ุฏูŠ ูˆุงู„ toolcine ุฏูŠ ุจู‚ู‰ ููŠู‡ ู…ู†ู‡ุง ู†ูˆุนูŠู† :

๐Ÿ-๐๐š๐ญ๐ข๐ฏ๐ž ๐“๐จ๐จ๐ฅ๐œ๐ก๐š๐ข๐ง:

-- This toolchain runs on the same type of architecture, sometimes the same actual system, as the programs it generates. This is the usual case for desktops and servers, and it is becoming popular on certain classes of embedded devices.
--ุงู„ Native ูŠุนู†ูŠ ุงู†ุช ุฌุจุช ุงู„ toolchain ู…ู† ุนู„ูŠ ุงู„ู†ุช ุนุงุฏูŠ ูˆุณุทุจุชู‡ุง ุนู†ุฏูƒ ุนู„ูŠ ุงู„ุงุจุชูˆุจ ุงูˆ ุงู„ host machine (ุงู„ุงุจุชูˆุจ ุจุชุงุนูƒ ุงู„ุจุฑูˆุณูŠุณูˆุฑ ุจุชุงุนู‡ ูŠ intel / AMD ) ูˆุงุณุชุฎุฏู…ุชู‡ุง ุนุดุงู† ุชุนู…ู„ generation ู„ูƒูˆุฏ ุจุงูŠู†ุฑูŠ ูˆู‡ูŠ run ุนู„ูŠ intel ุจุฑุถู‡โ€ฆ.ูˆุถุญู„ูŠ !

--ุญุงุถุฑ ูŠุง ุญุณู†
--ูƒู… ุงู„ุงุฎุฑ ู„ูˆ ุงู„ toolchain ู†ุฒู„ุช ุนู„ูŠ Architecture ุนุดุงู† ุช generate code ู‡ูŠุดุชุบู„ ุนู„ูŠ ู†ูุณ ุงู„ Architecture ุฏูŠ ูƒุฏุง native toolchain.
--ู…ุซุงู„ ุนู„ูŠ ูƒุฏุง ู„ู…ุง ุจุชูุชุญ eclipse ู…ุซู„ุง ูˆุชูƒุชุจ ูƒูˆุฏ c ุนุงุฏูŠ ูˆุดุบู„ุชู‡ ูŠุทุจุน hello world ู…ุซู„ุง ุงู†ุช ูƒุฏุง ุนู…ู„ุชู„ู‡ generation ุนู„ูŠ ุงู„ุงุจุชูˆุจ ุจุชุงุนูƒ ูˆุจุฑุถู‡ ุงู„ binary ุงู„ู„ู‰ ุทู„ุน ู‡ูŠุดุชุบู„ ุนู„ูŠ ุงู„ุงุจุชูˆุจ ุจุชุงุนูƒ (ู‡ูŠุฑู† ุนู„ูŠ ู†ูุณ ุงู„ู…ุนู…ุงุฑูŠุฉ ุงู„ู„ู‰ ุนู…ู„ุช ู„ูŠู‡ generation ุฏู‡ ูƒุฏุง native toolchain)

๐Ÿ-๐‚๐ซ๐จ๐ฌ๐ฌ ๐“๐จ๐จ๐ฅ๐œ๐ก๐š๐ข๐ง:

--This toolchain runs on a different type of architecture than the target, allowing the development to be done on a fast desktop PC and then loaded onto the embedded target.
--ู‡ู†ุง ุจู‚ู‰ ุนูƒุณ ุงู„ native ุงู†ุช ู†ุฒู„ุช ูˆุณุทุจุช ุงู„ toolchain ู…ู† ุนู„ูŠ ุงู„ู†ุช ูˆุงุณุชุฎุฏู…ุชู‡ุง ุนุดุงู† ุชุนู…ู„ generation ู„ binary code ู‡ูŠุดุชุบู„ ุนู„ูŠ target machine ุบูŠุฑ ุงู„ู…ุนู…ุงุฑูŠุฉ ุจุชุงุนุช ุงู„ุงุจุชูˆุจ ุจุชุงุนูƒ.
--ู‡ุฏูŠูƒ ู…ุซุงู„ ูŠุง ุญุณู† ุญุงุถุฑ
--ุฏู„ูˆู‚ุช ุงู†ุช ุฑูˆุญุช ูƒุชุจุช ูƒูˆุฏ ุนู„ูŠ atmel studio ุงูˆ STMCubeIDE ูˆู…ุนุงู‡ ุงู„ toolchain ุฏู„ูˆู‚ุช ุงู†ุช ุนู…ู„ุช ุงู„ gernation ,ูˆุงู„ develop ู„ู„ูƒูˆุฏ ุฏู‡ ููŠู† ุŸ
ุนู„ูŠ ุงู„ุงุจุชูˆุจ ุนู†ุฏูƒ ูˆุงู„ู„ูŠ ู‡ูˆ ุจูŠุฒุฏ ุนู„ูŠ intel architecture ูˆุงู„ binary code ุงู„ู„ู‰ ุทู„ุน ุฏู‡ ู‡ุดุชุบู„ ููŠู† ุŸ ุงูˆ ุนู„ูŠ ุงูŠู‡ ุŸ ู‡ูŠุดุชุบู„ ุนู„ูŠ ARM ุงูˆ AVR ู…ุซู„ุง ูŠุนู†ูŠ ู…ุด intel ุตุญ ุŸ
ู‡ูˆ ุฏู‡ ุจู‚ู‰ ุงู„ cross toolchain ุจุนู…ู„ generation ู„ูƒูˆุฏ ุนู„ูŠ architecture ุงูˆ ุจุฑูˆุณูŠุณูˆุฑ ู…ุนูŠู† ูˆู„ูƒู† ู‡ูˆ ู…ุด ู‡ูŠุดุชุบู„ ุนู„ูŠ ุงู„ same arctututrr ู„ุง ู‡ูŠุดุชุบู„ ุนู„ูŠ archtucure ุชุงู†ูŠู‡.

/******************/

--ูˆู…ุน ุงูˆู„ stage ููŠ ุงู„ build process ูˆู†ู‚ูˆู„ ุงู„ูˆูˆูˆูˆูˆ

๐Ÿ-๐๐ซ๐ž-๐๐ซ๐จ๐œ๐ž๐ฌ๐ฌ๐ข๐ง๐  ๐’๐ญ๐š๐ ๐ž:

--All preprocessing directives will be resolved
--The pre-processing performs a series of textual transformations on its input, these happen before all other processing.
1-macro
2-include
3-Conditions ( , , )
4-Merge continued line โ€˜\โ€™
5-Replace comments with single space
6-Inclusion of header files
7-Diagnostics ( , )
--ุงู„ -Pre-Processing ุจูŠุดูŠู„ ุงูŠ ุญุงุฌู‡ ูŠุณุจู‚ู‡ุง ุนู„ุงู…ุฉ ุงู„ #
--ูŠุนู†ูŠ ู„ูˆ ูƒู†ุช ุจุชุนู…ู„ ู…ุซู„ุง ู„ File ู…ุนูŠู† ู‡ูŠุฑูˆุญ ูŠุดูŠู„ ุงู„ ุฏู‡ ูˆูŠุญุท ุงู„ content ยญยญยญุจุชุงุน ุงู„ file ุฏู‡.
--ูˆู„ูˆ ุงู†ุช ูƒู†ุช ุนุงู…ู„ \ ุนุดุงู† ุชูุถู„ ุจูŠู† ุงู„ุณุทูˆุฑ ูู‡ูˆ ุจูŠุดู„ู‡ุง
--ูˆูƒุฐู„ูƒ ุจูŠุดู„ ุงู„ # ุงู„ู„ู‰ ู„ูˆ ู…ูƒุชูˆุจ ุฌู†ุจู‡ุง string ู„ู†ูุณ ุงู„ string ูˆู„ูƒู† ุจูŠู† double quotation
--ุงูˆ ู„ู‚ูŠ # # ูˆุฏูŠ ุงู„ู„ู‰ ุจุชุนู…ู„ concatiantion ุจูŠู† ุง ู„ starings ุฏูŠ ูˆุจุนุถู‡ุง
--ูƒุฐู„ูƒ ู„ู‚ูŠ ุงู„ุญุฌุงุช ุจุชุงุนุช ุงู„ condition ( , , )
ุชู‚ูˆู„ูŠ ุทุจ ู‡ูˆ ู…ุด ุนุดุงู† ูŠุชุดูƒ ุนู„ูŠ ุงู„ condition ุฏู‡ ู…ุญุชุงุฌ processor ูŠุนู…ู„ู‡ุง ุŸ ู‡ู‚ูˆู„ูƒ ุทุจุนุง ูŠุง ุญุณู† ู…ู‡ูˆ ุจูŠุนู…ู„ู‡ุง ุนู„ูŠ ุงู„ุจุฑูˆุณูŠุณูˆุฑ ุจุชุงุน ุงู„ host machine ุงู„ุงุจุชูˆุจ ุจุชุงุนูƒ ุงู†ุช
--ูƒุฐู„ูƒ ู…ุซู„ุง ู„ูˆ ุงู†ุง ุชูŠู… ู„ูŠุฏุฑ ูˆ ุนุงูŠุฒ ุงู†ุจู‡ ุนู„ูŠ ุจู‚ูŠุช ุงู„ุชูŠู… ุงู† ู‚ูŠู…ุฉ variable ู…ุนูŠู† ู„ุงุฒู… ุชุจู‚ูŠ ุจูƒุฐุง ู‚ูŠู…ู‡ ู…ุนูŠู†ู‡ ูŠุนู†ูŠ ูุงู†ุง ู…ู…ูƒู† ุงู‚ุฏุฑ ููŠ ุงู„ู…ุฑุญู„ู‡ ุฏูŠ ุงุนู…ู„ ุฌูŠู†ูŠุฑูŠุช ู„ warning ุงูˆ error ุงุฐุง ู„ู… ูŠุชุญู‚ู‚ ุงู„ู„ู‰ ุงู†ุง ู…ู†ุจู‡ ุนู„ูŠู‡
--ู…ู† ุฃู‡ู… ููˆุงูŠุฏ ุงู„ู…ุฑุญู„ู‡ ุฏูŠ ุงู†ู‡ุง ุจุชุนู…ู„ text replacement ู„ูƒู„ ุงู„ macros ุงู„ู„ู‰ ุงู†ุง ู…ุนุฑูู‡ุง ููˆู‚ ุจ ูˆุชูŠุฌูŠ ููŠ ุงู„ู…ุฑุญู„ู‡ ุฏูŠ ุชุฏูˆุฑ ุชุดูˆู ูƒู„ ุฏู‡ ูˆุชุจุฏู„ู‡ ุจุงู„ู‚ูŠู…ุฉ ุงู„ู…ุนุฑูˆูุฉ ู„ูŠู‡ุง ููˆู‚ ูˆูŠุทู„ุน ูุงูŠู„ ุงู„ .i ู…ููŠู‡ุด ุงูŠ ุญุงุฌู‡ ุชุจุน ุงู„ # ู„ุง ุงู†ูƒู„ูˆุฏ ู„ู„ูุงูŠู„ ูˆู„ุง ู„ macro ูุชุณุงุนุฏูƒ ุงู†ูƒ ุชุนู…ู„ const value.
--ูˆุงู„ output ุจุชุงุน ุงู„ Pre-Processing stage ู‡ูˆ( file.i (intermediate


/************************/

๐Ÿ-๐‚๐จ๐ฆ๐ฉ๐ข๐ฅ๐ž๐ซ ๐’๐ญ๐š๐ ๐ž

--Higher Level language code will be converted into processor architecture level assembly.
--Compiler works with one translation unit (parsed c file) at a time.
--Compiler allocates memory for definitions and generates opcodes for excitable statements.
--The compiler and assembler create relocatable object files (.obj)
--ููŠ ู…ุฑุญู„ุฉ ุงู„ compiler ูˆู‡ูŠ ุชุญูˆูŠู„ ุงู„ c code ู„ assembly code (ุฎุฏ ุจุงู„ูƒ ููŠ ุงู„ compilers ุงู„ุญุฏูŠุซุฉ ู‡ูŠูƒูˆู† ู…ุฏู…ุฌ ุฌูˆุงู‡ุง ุงู„ compiler +assembler ) ู„ูƒู† ุงุญู†ุง ู‡ู†ุง ุจู†ุชูƒู„ู… ุงู†ู‡ู… ู…ูุตูˆู„ูŠู† ุนู† ุจุนุถ ููƒุฏุง ุงู„ compiler ู‡ูŠุงุฎุฏ c code ูˆูŠุทู„ุนู„ูƒ assembly code ูˆุจูŠูƒูˆู† based ุนู„ูŠ ุงู„ architecture ุงู„ู„ู‰ ุงู†ุช ู…ุญุฏุฏู‡ุง.
--ู…ุฑุญู„ุฉ ุงู„ compiler ู‡ูŠ based ุนู„ูŠ ุงู„ Architecture ู„ุงู† ูƒู„ Architecture ู„ูŠู‡ ุงู„ Assembly ุงู„ุฎุงุต ุจูŠู‡.
--ูˆุทุจุนุง ุงู„ compiler ุจูŠุดุชุบู„ ุนู„ูŠ source file ูˆุงุญุฏ ููŠ ุงู„ู…ุฑุฉ ุงู„ูˆุงุญุฏุฉ.
--ููŠ ุงู„ compiler ู…ู…ูƒู† ุงุจุณุชุฑูƒุดู† ูƒุฏุง ู‡ูˆ ุจูŠุนู…ู„ ุงูŠู‡ ุŸ
--ุจูŠุนู…ู„ ุญุงุฌุชูŠู† ูŠุง ุญุณู† ุงู„ุงูˆู„ูŠ ุงู†ู‡ ูŠุญูˆู„ ุงู„ c code ุจุชุงุนูƒ ู„ machine code ูˆุงู„ุญุงุฌู‡ ุงู„ุชุงู†ูŠู‡ ุงู†ู‡ ูŠุญุฌุฒ ุงู„ memory ุจุชุงุนุชูƒ.
--ููŠ ุงู„ุบุงู„ุจ ุงู„ุจุฑูˆุฌูŠูƒุช ุจุชุงุนูƒ ุจูŠูƒูˆู† ููŠู‡ ุงูƒุชุฑ ู…ู† source code ูŠุนู†ูŠ ุจูŠูƒูˆู† ุนู†ุฏูƒ main.c , gpio.c , timer.c ,adc.c ุงู„ูƒูˆู…ุจูŠู„ุฑ ุจูŠู…ูƒุณ ูุงูŠู„ ูุงูŠู„ ูƒุฏุง ูˆูŠุจุชุฏูŠ ูŠุญู„ูˆู„ู‡ ู„ Assembly
--ุงู„ output ุจุชุงุน ุงู„ compiler ู„ูˆ ู‡ูˆ ู…ูุตูˆู„ ุนู† ุงู„ assembler ูู‡ูŠุทู„ุน ู„ูŠูƒ file.s.
--ุงู„ compiler ู…ู† ุฌูˆุง ู…ุชู‚ุณู… ู„ 3 stage ุชุนุงู„ูŠ ูŠุง ุญุณู† ุงุนุฑููƒ ุนู„ูŠู‡ู….


/******************/

-Compilation stages:

๐Ÿ-๐…๐ซ๐จ๐ง๐ญ ๐„๐ง๐

1-๐ฌ๐จ๐ฎ๐ซ๐œ๐ž ๐œ๐จ๐๐ž ๐ฉ๐š๐ซ๐ฌ๐ข๐ง๐ 

--ุงู„ Front end ูˆุฏูŠ ุจูŠุญุตู„ ููŠู‡ุง source code parsing ูˆู‡ูŠ ุงู† ุจู†ุชุจุชุฏูŠ ู†ูุตุต ุงู„ูƒูˆุฏ ุงู„ู…ูƒุชูˆุจ ู„ุญุชู‡ ุญุชู‡.
--ูˆุจูŠุนู…ู„ ู‡ู†ุง ุนู…ู„ูŠุฉ ุงู„ Tokenising ูˆู‡ูˆ ุงู†ู‡ ูŠุญุงูˆู„ ูŠูู‡ู… ุงู„ tokens ูˆุงูŠ ุงู„ูƒู„ู…ุงุช ุฏูŠ ู…ู† keywords , operators , identifier , literials ูˆูŠูู‡ู… ุจู‚ู‰ ุงุณุงู…ูŠ ุงู„ variables ูˆุงู„ functions.
--ุจูŠุนู…ู„ ุงู„ูƒู„ุงู… ุฏู‡ ุงุฐุงูŠ ุŸ
By

--๐’๐ฒ๐ง๐ญ๐š๐ฑ ๐€๐ง๐š๐ฅ๐ฒ๐ฌ๐ข๐ฌ

1-Ensure tokens are organized according to C rules.
2-To avoid compiler syntax errors
3-output = parse tree
--ูˆู‡ู†ุง ู‡ูˆ ุจูŠุญู„ู„ ุงู„ C code ุงู„ู„ู‰ ุงู†ุช ูƒุงุชุจู‡ ูˆูŠุดูˆูู‡ ู‡ู„ ู…ุชูˆุงูู‚ ู…ุน ุงู„ c stranded ูˆู„ุง ู„ุง ู„ูˆ ู„ู‚ูŠ ุญุงุฌู‡ ู…ุด ุฒูŠ ู… ุงู„ C ู‚ุงูŠู„ู‡ ุนู„ูŠู‡ุง ูƒ syntax ู‡ูŠุถุฑุจ compiler error .
--Intermediate representation
1-Transform parse tree into machine code intendant representation

/******************/

๐Ÿ-๐Œ๐ข๐๐๐ฅ๐ž ๐„๐ง๐

By:
๐Ÿ-๐’๐ž๐ฆ๐š๐ง๐ญ๐ข๐œ ๐š๐ฆ๐ฒ๐ฅ๐š๐ฌ๐ž๐ฌ

1-Adding info to the AST
2-Checks logical structure of the program
3-Problems found here are warnings rather than errors.
4-Program symbol table constructed; debug information inserted

--ู‡ู†ุง ุงู„ compiler ุจูŠุญุงูˆู„ ูŠูู‡ู… ู…ู† ุงู„ูƒูˆุฏ ุงู†ุช ุนุงูŠุฒ ุชุนู…ู„ ุงูŠู‡ ุงูˆ ุงู†ุช ุชู‚ุตุฏ ุงูŠู‡ ูƒ logic ูˆูŠุจุชุฏูŠ ูŠุนุฑู ุงุญุฌุงู… ุงู„ Data type ุงู„ู„ู‰ ุงู†ุช ูƒุงุชุจู‡ุง ูˆู„ู‚ูŠ ู…ุดูƒู„ู‡ ุงูˆ ุญุงุฌู‡ ููŠ ุงู„ู…ุฑุญู„ู‡ ุฏูŠ ุจุชูƒูˆู† warning ู…ุด error ุฒูŠ ุงู† ุญุงุฌู‡ ุชูƒูˆู† ุจุชุนู…ู„ conflict ุงูˆ ุงู†ู‡ ูŠูƒูˆู† ุดุงูƒูƒ ุงู†ูƒ ุงุชู„ุบุจุท ููŠ ุงู„ุญุชู‡ ุฏูŠ ุงูˆ ุงู†ู‡ุง ู…ู…ูƒู† ุชุชูู‡ู… ุจุฃูƒุซุฑ ู…ู† ู…ุนู†ู‰ ููŠู‚ูˆู„ูƒ ุฎุฏ ุจุงู„ูƒ ูŠุงุฑูŠุณ ุงู†ุช ุนุงู…ู„ pointer ู…ู† char ูˆ ุจุชุฎู„ูŠู‡ ูŠุดุงูˆุฑ ุนู„ูŠ ุญุงุฌู‡ int ูุชูŠุฌูŠ ุนุงู…ู„ casting ุงู†ุช ู„ู„ int ุนุดุงู† ุชู‚ูˆู„ู‡ ุงู†ุง ุนุงุฑู ู…ุชู‚ู„ู‚ุด ููŠุชุดุงู„ ุงู„ warning ุฏู‡.

๐Ÿ-๐Ž๐ฉ๐ญ๐ข๐ฆ๐ข๐ณ๐š๐ญ๐ข๐จ๐ง

1-Transforms the code into smaller or faster but functionality equivalent.
2-Multi level process includes:
--Inline expansion of functions
--Dead Code removal
--Loop unrolling
--Register allocation
--ุชุงู†ูŠ ู…ุฑุญู„ู‡ ููŠ ุงู„ middle end ู‡ูŠ ุงู„ optimization ูˆุฏูŠ ุงู„ู„ู‰ ุจูŠุญุตู„ ููŠู‡ุง ุชุญุณูŠู† ู„ู„ูƒูˆุฏ ุจุชุงุนูƒ ู…ู† ุญูŠุซ ูŠูƒูˆู† ุฃุณุฑุน ูƒ Ex*****on time ูˆูŠูƒูˆู† efficient ู…ู† ุญูŠุซ ุงุณุชุฎุฏุงู… ุงู„ memory.
--ุงู„ Optimization ุฒูŠ ู…ู‚ูˆู„ู†ุง ูˆู‡ูˆ ุงู† ุงู„ูƒูˆู…ุจูŠู„ุฑ ุจูŠุญุงูˆู„ ูŠุธุจุท ุงู„ code ุจุชุงุนูƒ ูˆูŠุฎู„ูŠู‡ ุงุณุฑุน ูƒ ex*****on ูˆ efficient ู…ู† ุญูŠุซ ุงู„ู…ูŠู…ูˆุฑูŠ ุงู„ู„ู‰ ุญุฌุฒู‡ุง ูˆุฏู‡ ุนู† ุทุฑูŠู‚ ุงู†ู‡ ู…ุซู„ุง ู…ู…ูƒู† ูŠู‚ู„ุจ function ุนุงุฏูŠู‡ ู„ inline function ูˆู‡ูˆ ุงู†ู‡ ุจุฏู„ ู…ูŠุฑูˆุญ ูŠุนู…ู„ jump ุนู„ูŠ ุงู„ address ุจุชุงุนู‡ุง ู„ุง ูŠุฑูˆุญ ูŠุฌูŠุจ ุงู„ูƒูˆุฏ ุจุชุงุนู‡ุง ูˆูŠุญุทู‡ ููŠ ู…ูƒุงู† ู…ู‡ูˆ ุดุบุงู„.
--ูƒุฐู„ูƒ ู„ูˆ ุญุงุฌู‡ ุฒูŠ ุงู„ dead code ูˆู‡ูˆ ุงู†ูƒ ูƒุงุชุจ ูƒูˆุฏ ุนู…ุฑู‡ ู…ุจูŠุชู†ูุฐ ูุงู„ูƒูˆู…ุจูŠู„ุฑ ุจูŠุนุฑู ุงู† ุงู„ุญุชู‡ ุฏูŠ ุณู‡ูˆ ู…ู†ูƒ ููŠุฌูŠ ุนุงู…ู„ ู„ูŠู‡ุง optimization ูˆ ูŠุญุฐูู‡ุง ุนุดุงู† ูŠู‚ู„ู„ ุญุฌู… ุงู„ binary ุงู„ู„ู‰ ุทุงู„ุน.
--ูƒุฐู„ูƒ ู…ู…ูƒู† ูŠุนู…ู„ Loop unrolling ูˆู‡ูˆ ุงู†ู‡ ูŠู‚ู„ุจ ู…ุซู„ุง ุงู„ For loop ู„ ุณุทูˆุฑ ูˆุฑุง ุจุนุถู‡ุง ุจุฏู„ ุงู„ loop ุญุฌู… ุงู„ูƒูˆุฏ ุงู‡ ุจูŠูƒุจุฑ ูˆู„ูƒู† ุจูŠูƒูˆู† ุงุณุฑุน ููŠ ุงู„ Education.
.
/******************/

๐Ÿ‘-๐๐š๐œ๐ค ๐„๐ง๐

๐Ÿ-๐‚๐จ๐๐ž ๐ ๐ž๐ง๐ž๐ซ๐š๐ญ๐ข๐จ๐ง
1-Converts optimized Intermodal Representation code structure into target opcodes.
--ุชุงู„ุช ู…ุฑุญู„ุฉ ูˆุฏูŠ ุงู„ู„ู‰ ุจูŠุญุตู„ ููŠู‡ุง ุงู„ Code generation ูˆุงู„ memory allocation.

๐Ÿ-๐Œ๐ž๐ฆ๐จ๐ซ๐ฒ ๐€๐ฅ๐ฅ๐จ๐œ๐š๐ญ๐ข๐จ๐ง
1-Compiler allocates memory for the code and data in sections
2-Sections have different info.
3-Sections defined by name or attributes of info stored in them.
4-Attributes are used by linker for locating sections in memory.

--ุชูŠุฌูŠ ุชุงู†ูŠ ู…ุฑุญู„ู‡ ููŠ ุงู„ back end ูˆู‡ูŠ ุงู„ memory allocation ุงู†ู‡ ูŠุญุฌุฒ ู…ุณุงุญุฉ ููŠ ุงู„ู…ูŠู…ูˆุฑูŠ ู„ู„ code ุงู„ู„ู‰ ุทู„ุน ุฏู‡ ูˆู„ู„ุฏุงุชุง ุงู„ู„ู‰ ุงู„ูƒูˆุฏ ุฏู‡ ุจูŠุณุชุฎุฏู…ู‡ุง ูˆุจูŠุญุฌุฒ ุงู„ู…ูŠู…ูˆุฑูŠ ุฏูŠ ููŠ ุตูˆุฑุฉ ุณูƒุงุดู† ูˆูƒู„ ุณูŠุดูƒู† ุจูŠูƒูˆู† ู„ูŠู‡ ุบุฑุถ ุงูˆ ุณุจุจ ู…ุนูŠู† ูˆู†ูˆุน ู…ู† ุงู„ุฏุงุชุง ุจูŠุดูŠู„ู‡ุง ูˆุจูŠุฏูŠ ู„ู„ Section ุงุณู… ูˆุจุนุถ ุงู„ attributes ุฒูŠ ู†ูˆุนู‡ ุงูŠู‡ ูŠู†ูุน ุงู‚ุฑุง ูˆุงูƒุชุจ ููŠู‡ ูˆู„ุง ุงู‚ุฑุง ุจุณ ุญุฌู…ู‡ ู‚ุฏ ุงูŠู‡ ุจูŠู†ุฒู„ ููŠ ู…ูŠู…ูˆุฑู‰ ู†ูˆุนู‡ุง ุงูŠู‡ ูˆูŠุฌูŠ ุงู„ linker ุจู‚ู‰ ูˆู‡ูˆ ุจูŠู„ูŠู†ูƒ ุงู„ู†ุงุณ ุฏูŠ ูƒู„ู‡ุง ูŠู…ู„ูƒ ูƒู„ ุงู„ุณูƒุงุดู† ุงู„ู„ู‰ ุดุจู‡ ุจุนุถ ููŠ ุณุดูƒู† ูˆุงุญุฏ.
--ุทุจ ุงูŠู‡ ุงู„ memory sections ุงู„ู„ู‰ ุนู†ุฏู†ุง ุŸ

/******************/

๐–๐ก๐š๐ญ ๐š๐ซ๐ž ๐ฆ๐ž๐ฆ๐จ๐ซ๐ฒ ๐ฌ๐ž๐œ๐ญ๐ข๐จ๐ง๐ฌ?
--ุจุต ู‡ู†ุง ุจูŠุทู„ุน ู„ูŠูƒ sections ุจุญุจ ุงุณู…ูŠู‡ุง ุงู„ุงุณุงุณูŠ ูˆููŠู‡ sections ุชุงู†ูŠู‡ ุจุชุทู„ุน ุจุฑุถู‡ ู‡ูŠ ุงู‡ ู„ุง ุชุญุชูˆูŠ ุนู„ูŠ ูƒูˆุฏ ูˆู„ุง ุนู„ูŠ ุฏุงุชุง ุชุฎุต ุงู„ูƒูˆุฏ ุจุณ ู…ู† ุบูŠุฑู‡ุง ุงู„ linker ูˆุงู„ debugger ุญุฑููŠุง ู‡ูŠุตุฑุฎูˆุง ู…ู†ูƒ ู„ูˆ ุงู„ุณูƒุงุดู† ุฏูŠ ู…ุทู„ุนุชุด
--ุงูŠู‡ ู‡ูŠ sections ุงู„ุงุณุงุณูŠู‡ ูˆุงู„ู„ูŠ ุชูƒูˆู† ุจุชุญุชูˆูŠ ุนู„ูŠ ูƒูˆุฏ ุงูˆ ุฏุงุชุง ุŸ
1-.bss
2-.data
3-.txet
4-.rodata
5-stack
6-heap
--ูƒู†ุช ู…ุชูƒู„ู… ุนู†ู‡ู… ููŠ ุงู„ุจูˆุณุช ุจุชุงุน ุงู„ start code ุชู‚ุฏุฑ ุชุฑูˆุญ ุชุดูˆูู‡ู… ู‡ู†ุงูƒ ุจุงู„ุชูุตูŠู„

/*********************/

๐–๐ก๐š๐ญ ๐ข๐ฌ ๐ญ๐ก๐ž ๐’๐ฒ๐ฆ๐›๐จ๐ฅ ๐ญ๐š๐›๐ฅ๐ž?
--ุฏูŠ ุจุชูƒูˆู† ูŠุง global symbols ุงูˆ private symbols
--ุงู„ symbol table ู…ู…ูƒู† ุชุนุชุจุฑู‡ ุญุงุฌู‡ ุจุชุฎุฒู† ููŠู‡ุง ุดูˆูŠุฉ ู…ุนู„ูˆู…ุงุช ุจูŠุชุฎุฒู† ููŠู‡ุง ุงูŠู‡ ุงู„ุงุณุงู…ูŠ ุงู„ู„ู‰ ุฌุงุช ููŠ ุงู„ code ูˆุงู„ุงุณุงู…ูŠ ุฏูŠ ุงู„ Attributes ุจุชุงุนุชู‡ุง ูƒุงู†ุช ุงูŠู‡ ุฒูŠ ุงูŠู‡ ุงุณุงู…ูŠู‡ุง ู‡ู„ ู‡ูŠ variable ูˆู„ุง function ูˆูƒุงู†ุช ู…ูˆุฌูˆุฏุฉ ููŠ ุงู†ูŠ Scope ูˆ ุงุชูƒุฑุฑุช ูƒุงู… ู…ุฑู‡ ู‡ู„ ุงู„ symbol ุฏู‡ ูƒุงู† global ูˆู„ุง private ุจุญูŠุซ ู„ู…ุง ุงู„ linker ูŠุฌูŠ ูŠู„ู†ูƒ ุงู„ููŠู„ุงุช ุจุจุนุถู‡ุง ูŠุจู‚ูŠ ู…ุนุงู‡ guide ูƒุฏุง ุจูŠู‚ูˆู„ู‡ ุงู„ file ุฏู‡ ุงูŠู‡ ูˆุถุนู‡ ููŠุฑู ูŠุฑุจุท ุงู„ู†ุงุณ ุฏูŠ ุจุจุนุถู‡ุง.

/*********************/

๐–๐ก๐š๐ญ ๐ข๐ฌ ๐ญ๐ก๐ž ๐ƒ๐ž๐›๐ฎ๐  ๐ข๐ง๐Ÿ๐จ?
--ุฏู‡ ุงู„ู„ู‰ ุจูŠุณุชุฎุฏู…ู‡ุง ุงู„ debugger ู„ูˆ ุญุจ ูŠุนู…ู„ digging ู„ู„ูƒูˆุฏ ุจุชุงุนูƒ ู„ุงู† ุงู„ debugger ู…ูŠูู‡ู…ุด ุงู„ zero / ones + ุงู† ุงู„ูƒูˆุฏ ุจุชุงุนูƒ ู…ู…ูƒู† ูŠูƒูˆู† ุงุชุนู…ู„ ู„ูŠู‡ optimization ูููŠู‡ ุญุฌุงุช ู…ู†ู‡ ุงุชุดุงู„ุช ูู‡ูˆ ุนุงูŠุฒ ุญุงุฌู‡ ุชุณุงุนุฏู‡ ููŠ ุงู†ู‡ ูŠุจู‚ูŠ ุนุงุฑู ุงู„ุฌุฒุก ุฏู‡ ุจุชุงุน ุงู„ูุงู†ูƒุดู† ุฏูŠ ุงูˆ ุชู…ุงุจ ุงู„ source code ู„ู„ binary code ุฏู‡

/*********************/

--ุนู†ุฏูƒ ุจู‚ู‰ ุณูƒุดู†ูŠู† ู…ู‡ู…ูŠู† ุฌุฏุง ุฌุฏุง ุฌุฏุง ู„ู„ุตุจุญ ูŠุง ุญุณู† ูˆุฑูƒุฒ ู‡ู†ุง ุฌุงู…ุฏ
๐Ÿ-๐„๐ฑ๐ฉ๐จ๐ซ๐ญ
--ูˆุฏู‡ ุงู„ู„ู‰ ุจูŠุชุฎุฒู† ููŠู‡ ุงู„ global simple ุณูˆุงุก functions ุงูˆ variables ูˆุนุฑู ู…ุนูˆู„ู…ุฉ ุงู„ global ุฏูŠ ู…ู† ุงู„ symbol table
--ููŠ ุงู„ุณูƒุดู† ุฏู‡ ุจูŠุฎุฒู† ุงู„ symbols ุงู„ู„ู‰ ุงู†ุช ูƒ File ุจุชุนู…ู„ ู„ูŠู‡ุง Export ู„ููŠู„ุงุช ุชุงู†ูŠู‡ ูˆูŠุจู‚ูŠ ู…ุนุฑู ูˆุงู„ symbol ุฏู‡ giver

๐Ÿ-๐ข๐ฆ๐ฉ๐จ๐ซ๐ญ
--ูˆุฏู‡ ุจูŠุฎุฒู† ููŠู‡ ุงู„ุญุงุฌุงุช ุงู„ู„ู‰ ุงู†ุช ู…ุญุชุงุฌู‡ุง ู…ู† ุจุฑู‡ ุงู„ file ุฏู‡
--ูˆู‡ู†ุง ุจูŠุชุฎุฒู† ุงู„ุญุงุฌุงุช ุงู„ู„ู‰ ุจุชูƒูˆู† required ู…ู† ููŠู„ุงุช ุชุงู†ูŠู‡ ุจุชู†ุงุฏูŠ ุนู„ูŠ function ูˆู‡ูŠ ู…ุชุนุฑูู‡ ููŠ ูุงูŠู„ ุชุงู†ูŠ ุจุชู†ุงุฏูŠ ุนู„ูŠ variable ูˆู‡ูˆ ู…ุชุนุฑู ููŠ ูุงูŠู„ ุชุงู†ูŠ ( ุทุจุนุง ุงู„ูุงู†ูƒุดู† ุงู†ุช ู…ุนุฑู ุงู„ prototype ุจุชุงุนู‡ุง ุนุดุงู† ุชุนุฏูŠ ู…ู† ุงู„ compiler ูˆุงู„ู„ูŠู†ูƒุฑ ู‡ูŠุจู‚ูŠ ูŠ link ุจู‚ู‰ ุจูŠู†ู‡ุง ูˆุจูŠู† ุงู„ binary code ุงูˆ ุงู„ Definition ุงู„ู…ู‚ุงุจู„ ู„ูŠู‡ุง ูˆุนุดุงู† ูƒุฏุง ู„ู…ุง ุจูŠุทู„ุน ู„ูŠูƒ ุงูŠุฑูˆุฑ undefined reference ุงู„ุงูŠุฑูˆุฑ ุฏู‡ ุจูŠูƒูˆู† ุทุงู„ุน ู„ูŠูƒ ู…ู† ุงู„ู„ูŠู†ูƒุฑ ุงู†ู‡ ู„ู…ุง ูŠุฑุจุท ุจูŠู† ุงุณู… ุงู„ูุงู†ูƒุดู† ู…ู„ู‚ู‡ุงุด ููŠ ุงูŠ ูุงูŠู„ ุชุงู†ูŠ ูˆุชุญุฏูŠุฏุง ู…ู„ู‚ุงุด ุงู„ุงุณู… ุงูˆ ุงู„ symbol ุจุชุงุนู‡ุง ููŠ ุงู„ Export section ู…ุนู†ูŠ ูƒุฏุง ุงู†ู‡ ู…ุด ู…ุนู…ูˆู„ ู„ูŠู‡ุง giver ูˆุจุงู„ุชุงู„ูŠ ุงู„ู„ูŠู†ูƒุฑ ู‡ูŠุทู„ุน ู„ูŠูƒ ุงูŠุฑูˆุฑ ูˆูŠู‚ูˆู„ูƒ ุงุฑุญู…ู†ูŠ ุงู†ุง ู…ุด ู„ุงู‚ูŠ ุงู„ symbol ุฏู‡ ูˆู…ุด ุนุงุฑู ุงุฑุจุท ุจูŠู† ุงู„ import ุงู„ู„ู‰ ุงู†ุช ุนุงูŠุฒู‡ ุฏู‡ ูˆุจูŠู† ุงู„ export.
.
/*********************/

๐Ÿ‘-๐€๐ฌ๐ฌ๐ž๐ฆ๐›๐ฅ๐ž๐ซ
--It takes the assembly source code and produces an assembly listing with offsets.
--The assembler output is stored in the object file.
--ูˆู‡ูˆ ุงู†ู‡ ุจูŠุงุฎุฏ ุงู„ file.s ูˆูŠุญูˆู„ู‡ ู„ file.obj ูˆุฏู‡ ุงู„ู„ู‰ ุจูŠูƒูˆู† binary ุงุตูุงุฑ ูˆูˆุญุงูŠุฏ ูˆุฏู‡ ุงู„ู„ู‰ ุจูŠุชุนู…ู„ู‡ linking ู…ุน ุจู‚ูŠุช ุงู„ููŠู„ุงุช ุงู„ู„ู‰ ููŠ ุงู„ุจุฑูˆุฌูŠูƒุช ูˆูŠุชุนู…ู„ู‡ burn ุนู„ูŠ ุงู„ microcontroller.
--ู‡ู†ุง ู‡ูˆ ุจูŠุทู„ุน ุงู„ binary ุงู„ู…ูƒุงูุฆ ู„ูƒู„ ุงู„ instruction ูˆูŠู‚ุณู…ู‡ ุจู‚ู‰ ู„ opcode ูˆ operands
.
๐Ž๐›๐ฃ๐ž๐œ๐ญ ๐…๐ข๐ฅ๐ž๐ฌ
--Object file contains opcodes and data sections.
--Object file only contains the sections for static or predefined variables (the variables which defined before the compilation not in run time)
--The .o file is not (yet) excitable because static and global addresses are offsets from the start of their sections.
--ูˆู‡ู†ุง ุจู‚ูˆู„ูƒ ุงู† ุงู„ู„ู‰ ุจูŠุจู‚ู‰ ุทุงู„ุน ููŠ ุงู„ object code ูˆู‡ูŠ ุงู„ Static variables ูˆู‡ูŠ ุงู„ู„ู‰ ุจุชูƒูˆู† ุนุงูŠุดู‡ ุทูˆู„ ุงู„ุจุฑู†ุงู…ุฌ (ุฒูŠ ุงู„ุฏุงุชุง ุงู„ู„ู‰ ุงุชุฎุฒู†ุช ููŠ ุงู„ .bss / .data / .rodata ) ุฏูˆู„ ุซุงุจุชูŠู† ูˆู…ูˆุฌูˆุฏูŠู† ุทูˆู„ ุงู„ุจุฑู†ุงู…ุฌ ู…ุด ุดูˆูŠู‡ ูˆู‡ุชู…ูˆุช (ุฒูŠ ุงู„ local variables ุงูˆ ุงู„ heap ุฏูˆู„ ุจูŠุชุญุฌุฒูˆุง ููŠ ุงู„ run time ู…ุด ููŠ ุงู„ compilation time ) ูˆู…ุจูŠุจู‚ูˆุด ุนุงูŠุดูŠู† ุทูˆู„ ุงู„ุจุฑู†ุงู…ุฌ (ู…ุชุฎู„ุทุด ุจูŠู† ูƒู„ู…ุฉ static ุงู„ู„ู‰ ููˆู‚ ุฏูŠ ูˆุงู„ู„ูŠ ู…ุนู†ุงู‡ุง ุงู† ุงู„ู…ุชุบูŠุฑ ู…ุญุฌูˆุฒ ู…ู† ู‚ุจู„ ุงู„ run timer ูˆุนุงูŠุด ุทูˆู„ ุงู„ุจุฑู†ุงู…ุฌ ูˆุจูŠู† ุงู„ static keyword ุจุชุงุนุช ุงู„ c)
--Addresses defined in other modules are not known at all , except by name (symbol).
.
/**************************/

๐Ÿ’-๐‹๐ข๐ง๐ค๐ž๐ซ

-- ูŠุนู†ูŠ ู…ุซู„ุง ุทู„ุน uart.o , lcd.o , gpio.o , adc.o
--ุทุจ ู…ู†ุง ุนุงูŠุฒ ุงุฌู…ุน ุงู„ูุงูŠู„ุงุช ุฏูŠ ูƒู„ู‡ุง ู…ุน ุจุนุถ ุนุดุงู† ุงุทู„ุน ุงู„ุจุงูŠู†ุฑูŠ ุงู„ู†ู‡ุงุฆูŠ ุงู„ู„ูŠ ู‡ุฑูˆุญ ุงุนู…ู„ู‡ ุจูŠุฑู† ุนู„ูŠ ุงู„ุจูˆุฑุฏู‡.
--ู…ูŠู† ุจู‚ู‰ ู‡ูŠุนู…ู„ูŠ ุฏู‡ ุŸ
--ูˆูŠุนู†ูŠ ุงูŠู‡ ู‡ูŠุฌู…ุน ุงู„ูุงูŠู„ุงุช ุฏูŠ ู…ุน ุจุนุถู‡ุง ุŸ
--ูˆุฅุฐุง ุจูŠุฌู…ุนู‡ุง ุงุตู„ุงุŸ
--ุงุฒุงูŠ ุงุฑุณู… ุงู„ layout ุจุชุงุนูŠุŸ
--ูˆุงุฒุงู‰ ุงุญุท ุงู„ reset section ุงูˆ ุงูŠ section ุนู†ุฏ ู…ูƒุงู† ู…ุนูŠู†

--The linker script is a text file made up of a series of linker directives which tells the linker where the available memory is and how it should be used.
--reflect exactly the memory resources and memory map of the target microcontroller
--you have to use the linker script at the linking phase by pass to
the linker -T

--ุงู„ linker script ู‡ูˆ script ุจูŠุงุฎุฏ ู…ุฌู…ูˆุนุฉ objects ู…ุน ุจุนุถ ุนุดุงู† ูŠุนู…ู„ู‡ุง linking ูŠุนู†ูŠ ุจูŠุงุฎุฏ ูƒู„ ุงู„ุณูƒุงุดู† ุงู„ู„ู‰ ููŠ ูƒู„ ูุงูŠู„ ูˆูŠุงุฎุฏ ู…ู†ู‡ุง ูƒู„ ุณูƒุดู† ู…ุน ุงู„ุณูƒุดู† ุงู„ู…ู†ุงุธุฑ ู„ูŠู‡ ููŠ ุงู„ูุงูŠู„ ุงู„ุชุงู†ูŠ ูˆุงู„ุชุงู„ุช ูˆู‡ูƒุฐุง ูˆูŠุทู„ุนู‡ู… ููŠ ุณุดูƒู† ูƒุจูŠุฑ.
---ูŠุนู†ูŠ ู„ูˆ ุจุตูŠุช ุนู„ูŠ ุงู„ุตูˆุฑู‡ ุงู„ู„ู‰ ุชุญุช ูƒู„ ูุงูŠู„ ุจูŠูƒูˆู† ู…ุชู‚ุณู… ู„ sections ุฒูŠ ู…ู†ุชุง ุนุงุฑู .bss , .data , .text ู‡ูˆ ู‡ูŠุงุฎุฏ ุจู‚ู‰ ูƒู„ ุงู„ .bss ู…ู† ูƒู„ ุงู„ files ูˆูŠุทู„ุนู‡ู… ููŠ ุณูƒุดู† ููŠ ุงู„ูุงูŠู„ ุงู„ู†ู‡ุงุฆูŠ ุงุณู…ู‡ .bss ูˆู‡ูŠุงุฎุฏ ูƒู„ ุงู„ .text ู…ู† ุงู„ files ูˆูŠุทู„ุนู‡ู… ููŠ ุงู„ .text ุงู„ู†ู‡ุงุฆูŠ ูˆู‡ูƒุฐุง ูƒู„ ุงู„ุณูƒุงุดู† ุงู„ู„ู‰ ุดุจู‡ ุจุนุถ ูŠู„ู…ู‡ุง ููŠ ุณูƒุดู† ูˆุงุญุฏ.
--ุทุจ ู‡ู„ ูŠู„ุฒู… ุงู† ู„ู…ุง ุฃุฌู…ุน ูƒู„ ุงู„ .text ู…ุซู„ุง ู…ู† ูƒู„ ุงู„ูุงูŠู„ุงุช ู‡ู„ ู„ุงุฒู… ุงุทู„ุนู‡ู… ููŠ ุณูƒุดู† ุงุณู…ู‡ .text ุŸ
--ู„ุง ูŠุง ุญุณู† ู…ุด ุดุฑุท ู…ู…ูƒู† ุชุทู„ุนู‡ู… ููŠ ุณูƒุดู† ุงุณู…ู‡ .ุญุณู† ู…ุญุฏุด ู‡ูŠู‚ูˆู„ูƒ ุญุงุฌู‡ ูˆุงู„ุฏู†ูŠุง ู‡ุชุดุชุบู„ ุนุงุฏูŠ
ูˆู„ูƒู† ู„ูŠู‡ ุชุนู…ู„ ุญุงุฌู‡ ุฒูŠ ูƒุฏุง ุงุตู„ุง !
--ูƒู„ ุงู„ .text ูŠุชุฌู…ุน ููŠ .text ูƒู„ ุงู„ .bss ูŠุชุฌู…ุน ุชุญุช ุณูƒุดู† ุงุณู…ู‡ .bss ูˆู„ูƒู† ู‡ูˆ ู…ู† ุญูŠุซ ูŠู†ูุน ู ุงู‡ ูŠู†ูุน.
--ุฎุฏ ุจุงู„ูƒ ุงู†ุช ุงู„ูุงูŠู„ุงุช ุงู„ู„ู‰ ุงู†ุช ุจุชุฌู…ุนู‡ุง ุณูˆุง ุฏูŠ ูˆุจุชุนู…ู„ู‡ุง link ุจุชูƒูˆู† relocatable image ูŠุนู†ูŠ ู…ุจุชูƒูˆู†ุด ุนุงุฑูู‡ ุงู„ location ุจุชุงุนู‡ุง ููŠู† ููŠ ุงู„ physical ุนุดุงู† ูƒุฏุง ู„ูˆ ุชูุชูƒุฑ ูƒู†ุช ุจุชุทู„ุน ุงู„ูุงูŠู„ ู…ู† ุงู„ compiler ุงุณู…ู‡ relocatable file ู„ุงู† ู„ุณู‡ ู…ูŠุนุฑูุด ุงู„ู…ูƒุงู† ุงู„ู„ู‰ ู‡ูŠู†ุฒู„ ููŠู‡.
--ูˆู„ุฐู„ูƒ ุงู„ Linker script ู‡ูˆ ุจูŠุฒุฏ ุนู„ูŠ ุงู„ target microcontroller ู„ุงู† ู‡ูˆ ุงู„ู„ู‰ ุจูŠู‚ูˆู„ ุงู„ุญุงุฌุงุช ุฏูŠ ู‡ุชุชุญุท ููŠู† ูู„ุงุฒู… ูŠูƒูˆู† ุนุงุฑู ุงู„ addresses ููŠ ุงู„ microcontroller ุนุงู…ู„ู‡ ุงุฐุงูŠ.
--ุงู„ Linker script ุฒูŠ ู…ู‚ูˆู„ุช ููˆู‚ ู‡ูˆ ูุงูŠู„ ุนุงุฏูŠ ุงู„ุงุฎุชุตุงุฑ ุจุชุงุนู‡ ุจูŠูƒูˆู† .ld ุงู†ุช ุจุชูƒุชุจู‡ ุจ syntax ู…ุนูŠู† ูˆุจูŠูƒูˆู† ู„ูŠู‡ ู…ุฌู…ูˆุนุฉ commands ุจุชุณุชุฎุฏู…ู‡ุง

/**************************/

๐–๐ก๐š๐ญ ๐ข๐ฌ ๐š ๐ฅ๐จ๐œ๐š๐ญ๐ข๐จ๐ง ๐œ๐จ๐ฎ๐ง๐ญ๐ž๐ซ ? ๐–๐ก๐ฒ ๐๐ข๐ ๐ฐ๐ž ๐ฎ๐ฌ๐ž ๐ข๐ญ?
--linker symbol โ€˜.โ€™ dot
--this dot is called โ€œlocation counter โ€œ it is automatically
addressed calculated by each section size.
--we can use it to track and define the memory layout boundaries
--also we can use it to specify a specific address for a specific section
--location counter should be used only in section commands
--ูŠุนู†ูŠ ุงูŠู‡ Location counter ุŸ
--ุฏู‡ ุฌู†ุฏูŠ ู…ุฌู‡ูˆู„ ูˆู…ุญุฏุด ุญุงุณุณ ุจูŠู‡ ู„ูƒู† ุจูŠุนู…ู„ ุดุบู„ ุฌุจุงุฑ
--ู…ุด ู‚ูˆู„ู†ุง ู‚ุจู„ ูƒุฏุง ุงู† ุจุญุท ุงู„ reset section ุนู†ุฏ ุงู„ entry point ุนุดุงู† ุงู„ cpu ู„ู…ุง ุจูŠู‚ูˆู… ุจูŠุฑูˆุญ ููŠ ุงู„ู…ูƒุงู† ุฏู‡ ูˆุงู†ุง ุนุงูŠุฒ ุงู„ reset section ู‡ูˆ ุงูˆู„ ุญุงุฌู‡ ุชุดุชุบู„ ุŸ
-ู‚ูˆู„ู†ุง ูุนู„ุง
--ุทุจ ุงุฐุงูŠ ุงุญุท ุงู„ Section ุฏู‡ ุจู‚ู‰ ุนู†ุฏ ุงู„ entry point ุงู„ู„ู‰ ู„ูˆ ู†ูุชุฑุถ ุงู„ุนู†ูˆุงู† ุจุชุงุนู‡ุง 0x200000 !
--ู‡ู†ุง ุจู‚ู‰ ูŠุธู‡ุฑ ุฏูˆุฑ ุงู„ Linker locator
-- ุงู„ linker locator ุฏู‡ ุจู‚ู‰ ูƒุงู†ู‡ ุจูŠุดุงูˆุฑ ุนู„ูŠ ุงู„ู…ูƒุงู† ุฏู‡ ูŠุนู†ูŠ ุงุฎู„ูŠู‡ ููŠ ุงู„ุงูˆู„ ู…ุซู„ุง ุจูŠุณุงูˆูŠ ุนู†ูˆุงู† ู…ุนูŠู† ูˆูƒู„ ู…ุญุท section ู‡ูˆ ูŠุญุณุจ ุงู„ section ุฏู‡ ุงุฎุฏ ู‚ุฏ ุงูŠู‡ ูˆูŠุณุฌู„ ููŠ ู†ูุณู‡ ุชู„ู‚ุงุฆูŠ ุงู„ุนู†ูˆุงู† ุงู„ู„ู‰ ุนู„ูŠู‡ ุงู„ุฏูˆุฑ ุฏู„ูˆู‚ุช ุจุนุฏ ู†ู‡ุงูŠุฉ ุงู„ Section ุฏู‡.

/****************************/

--ู‡ู†ุง ู…ุซู„ุง ู„ูˆ ุงู†ุช ูƒู†ุช ุจุชู†ุฏู‡ ู„ prinf ุฏูŠ ุจุชูƒูˆู† ู…ูˆุฌูˆุฏุฉ ููŠ ุงู„ static library ูˆู‡ุฏูŠ ุจู†ูƒูˆู† object file ุจุงูŠู†ุฑูŠ ูŠุนู†ูŠ ูˆุงู†ุช ุจุช include ุงู„ .h ุจุชุงุนู‡ ูˆุชูŠุฌูŠ ููŠ ู…ุฑุญู„ุฉ ุงู„ linker ุชู†ุฏู‡ ุนู„ูŠ ุงู„ code ุงู„ู„ู‰ ู…ูˆุฌูˆุฏ ููŠ ุงู„ static library ูˆุงู„ู„ูŠ ู‡ูˆ ู‡ูŠูƒูˆู† ู…ูƒุงูุฆ ู„ู„ prinf
--ุงู„ file.obg ู„ูˆุญุฏู‡ ุบูŠุฑ ูƒุงููŠ ุงู†ู‡ ูŠู†ุฒู„ ุนู„ูŠ ุงู„ู…ูŠูƒุฑูˆูƒู†ุชุฑูˆู„ุฑ ู„ุงู†ู‡ ู„ุณู‡ relocatable file (ูŠุนู†ูŠ ู…ูŠุนุฑูุด ุงู„ addresses ุงู„ุญู‚ูŠู‚ูŠุฉ ุจุชุงุนุช ุงู„ู…ูŠูƒุฑูˆูƒู†ุชุฑูˆู„ุฑ ุงู„ู„ู‰ ุงู†ุช ู‡ุชู†ุฒู„ ุงู„ูƒูˆุฏ ุนู„ูŠู‡ ู„ูƒู† ุงู„ relocatable ุงู„ุงุฏุฑูŠุณูŠุฒ ุงู„ู„ู‰ ููŠู‡ ู…ุฌูˆุฏ offsets ุจุณ ู„ูƒู† ู…ุด ุงุฏุฑูŠุณูŠุฒ ุญู‚ูŠู‚ูŠู‡) + ุงู† ู„ูŠู‡ ููŠู‡ samples ู…ูˆุฌูˆุฏุฉ ููŠ ููŠู„ุงุช ุชุงู†ูŠู‡ ูู„ุณู‡ ุงู„ file.obj ุฏู‡ ุนุงูŠุฒ ูŠุนู…ู„ link ู…ุนุงู‡ุง ู‡ูˆ ู…ุนุงู‡ ุงู„ symbol ุจุชุงุนู‡ุง ุจุณ ู„ูƒู† ู„ุณู‡ ุนุงูŠุฒ ูŠุฌูŠุจ ุงู„ defination ุงูˆ ุงู„ุจูŠู†ุฑูŠ ุจุชุงุนู‡.
--ูŠุนู†ูŠ ุงู†ุช ู…ุซู„ุง ู„ูˆ ูƒู†ุช ููŠ File.c ุฏู‡ ุจุชู†ุฏู‡ ุนู„ูŠ ADC_read() ูˆุฏูŠ ูุงู†ูƒุดู† ู…ูˆุฌูˆุฏุฉ ููŠ ูุงูŠู„ ุชุงู†ูŠ ู‡ูŠ ุฏู„ูˆู‚ุช ุจู‚ู‰ ุจุงู„ู†ุณุจู‡ ู„ file.c ุฏูŠ not resolved ู„ุณู‡ ุนุงูŠุฒูŠู† ููŠ ุงู„ู„ูŠู†ูƒ ูŠุฑูˆุญ ูŠุฌูŠุจ ุงู„ DEfination ุงูˆ ุงู„ุจุงูŠู†ุฑูŠ ุงู„ู…ู‚ุงุจู„ ู„ูŠู‡ุง ู…ู† ุงู„ูุงูŠู„ ุงู„ุชุงู†ูŠ ูˆูŠุฑุจุทู‡ู… ุจุจุนุถ ุฏู‡ ุจูŠุญุตู„ ุงุฐุงูŠ ุŸ ู‡ู‚ูˆู„ูƒ ูŠุง ุญุณู† ูƒู…ุงู† ุดูˆูŠู‡ ู…ุชุณุชุนุฌู„ุด

--ุทุจุนุง ู…ู…ูƒู† ุงู„ุจุฑูˆุฌูŠูƒุช ุจุงู„ุนูŠ ู‡ูˆ ูุงูŠู„ ู„ูˆุงุญุฏู‡ ูˆู„ูŠูƒู† main.c ุชู‚ูˆู„ูŠ ูƒุฏุง ุจู‚ู‰ ุงู„ linker ู…ู„ูˆุด ู„ุงุฒู…ู‡ ุงู‚ูˆู„ูƒ ุงู‚ุณู… ุจุงู„ู„ู‡ ุนูŠุจ ูŠุนู… ูˆุงู„ู„ู‡ ุนูŠุจ ุงู„ู„ู‰ ุงู†ุช ุจุชู‚ูˆู„ู‡ ุฏู‡ !
--ุงุฐุงูŠ ูŠุง ุญุณู† ุจุณ ู…ุงู„ูˆุด ู„ุงุฒู… ุŸ
--ู‡ูˆ ุงู‡ ูุงูŠู„ ูˆุงุญุฏ ุจุณ ูˆู…ุด ุจูŠู†ุฏู‡ ููŠู‡ ุนู„ูŠ ุงูŠ ุญุงุฌู‡ ู…ูˆุฌูˆุฏู‡ ููŠ ูุงูŠู„ ุชุงู†ูŠ ุชู…ุงู… ูˆู„ูƒู† ู…ุด ุงู†ุง ู‚ุงูŠู„ูƒ ุงู† ุงู„ file ู‚ุจู„ ุงู„ link ูˆูŠูƒูˆู† relatable file ูŠุนู†ูŠ ุงู„ุงุฏุฑูŠุณูŠุฒ ุงู„ู„ู‰ ููŠู‡ ูƒู„ู‡ุง ุงูˆูุณุช ูˆ virtual addresses ุงู„ู„ูŠู†ูƒุฑ ุจู‚ู‰ ู‡ูˆ ุงู„ู„ู‰ ู‡ูŠุงุฎุฏ ุงู„ูุงูŠู„ ุฏู‡ ูŠุญุทู‡ูˆู„ูƒ ุนู†ุฏ ุงู„ุงู…ุงูƒู† ุงู„ุตุญ ุจุชุงุนุชู‡ ุทุจู‚ุง ู„ู„ target ุงู„ู„ู‰ ุงู†ุช ุดุบุงู„ ุนู„ูŠู‡
--ูŠุจู‚ูŠ ุฎุฏ ู„ูˆ ุงู„ุจุฑูˆุฌูŠูƒุช ุจุชุงุนูŠ ู‡ูˆ ูุงูŠู„ ูˆุงุญุฏ ูู‡ูˆ ุบูŠุฑ ู…ุคู‡ู„ ุจุฑุถู‡ ุงู†ูŠ ุงุฎุฏู‡ ุงู†ุฒู„ู‡ ุนู„ูŠ ุงู„ู…ูŠูƒุฑูˆ ุนู„ูŠ ุทูˆู„ ู„ุง ู„ุงุฒู… ูŠุนุฏูŠ ุนู„ูŠ ุงู„ู„ูŠู†ูƒุฑ ูŠุธุจุท ู„ูŠู‡ ุงู„ุงุฏุฑูŠุณูŠุฒ ุงู„ู„ู‰ ู‡ูŠู†ุฒู„ ููŠู‡ุง ุทุจู‚ุง ู„ู„ target board.
By:

๐Ÿ-๐’๐ฒ๐ฆ๐›๐จ๐ฅ๐ž ๐ซ๐ž๐ฌ๐จ๐ฅ๐ฎ๐ญ๐ข๐จ๐ง:

1-Resolve references between objects.
2-Unresolved symbols are searched for in libraries to resolve.
3-No resolution = Unresolved reference error
4-If linker finds the same symbol defined in two object files it will report a โ€œredefinitionโ€ error.

--ุงู„ symbol resolution !
--ู…ุด ุงุญู†ุง ุงุชูู‚ู†ุง ุงู† ูƒู„ obj file ุจูŠุทู„ุน ููŠู‡ ุงุชู†ูŠู† symbol table ูˆุงุญุฏ export ุฃูˆ giver ูˆุฏู‡ ุจูŠุฏู„ูƒ ุงุณุงู…ูŠ ุงู„ samples ุงู„ู„ู‰ ู‡ูŠ ุจูŠุนู…ู„ูƒ ู„ูŠู‡ุง Support ูˆุงู„ุชุงู†ูŠ ุงู„ import ุงูˆ ุงู„ required ูˆู‡ูˆ ุงู„ู„ู‰ ุจูŠุจู‚ู‰ ุจูŠุทู„ุจ ุงู„ symbols ุฏูŠ
--ูˆูŠุจุชุฏูŠ ูŠุดูˆู ุงูŠู‡ ุงู„ู„ู‰ ุงู„ูŠ ูƒู„ ูุงูŠู„ ุทุงู„ุจู‡ ููŠ ุงู„ import ูˆูŠุฑูˆุญ ูŠุฏูˆุฑ ุนู„ูŠู‡ ููŠ ุงู„ export ุนุดุงู† ูŠูˆูู‚ ุฑุงุณูŠู† ููŠ ุงู„ุญู„ุงู„ ๐Ÿ˜‚

ู…ู„ุงู‚ู‡ุงุด ููŠ ุงู„ููŠู„ุงุช ุงู„ู„ู‰ ุงู†ุช ุนุงู…ู„ ู„ูŠู‡ุง static library ูŠุฑูˆุญ ูŠุดูˆูู‡ุง ููŠ ุงู„ static library ู…ู„ู‚ู‡ุงุด ูŠุฌูŠ ู…ุฒุนู‚ ููŠ ูˆุดูƒ ูˆู‚ุงูŠู„ูƒ undefined symbol ุงูˆ ุงู†ู‡ ู…ุซู„ุง ูŠู„ุงู‚ูŠ ุงูƒุชุฑ ู…ู† definition ุงูˆ export ู„ู†ูุณ ุงู„ required ุฃูˆ ุงู„ symbol ููŠุฌูŠ ู…ุฒุนู‚ ููŠ ูˆุดูƒ ุจุฑุถู‡ ูˆูŠุฌูŠ ู‚ุงูŠู„ ู„ูŠูƒ multiple definition ูˆ ุงู†ุธุจุช ุจู‚ู‰ ูŠุงุนู… ู…ุชุดุชุบู„ู†ูŠุด ู…ุนุงูƒ ุฑูƒุฒ ูˆ ุฑูƒุฒ ู…ูŠู†ูุนุด ููŠ ุงูƒุชุฑ ู…ู† Export ุงู„ุงู‚ูŠ ู†ูุณ ุงู„ name ู„ู†ูุณ ุงู„ symbol.


๐Ÿ-๐’๐ž๐œ๐ญ๐ข๐จ๐ง ๐œ๐จ๐ง๐œ๐š๐ญ๐ž๐ง๐š๐ญ๐ข๐จ๐ง

1-Concatenating like-named sections from the input object files.
2-Program addresses are adjusted to take account of the concatenation.
--ูˆู‡ู†ุง ู‡ูŠุจุชุฏูŠ ูŠุฌู…ุน ูƒู„ ุงู„ู†ุงุณ ุงู„ู„ู‰ ุดุจู‡ ุจุนุถู‡ุง ู…ุน ุจุนุถ ููŠ ุณูƒุดู† ูˆุงุญุฏ ุฒูŠ ู…ู‚ูˆู„ู†ุง ููˆู‚ ูƒู„ ุงู„ .txt ูŠุทู„ุนู„ู‡ ููŠ .txt ูƒุจูŠุฑ , ูƒู„ ุงู„ .data ูŠุทู„ุนู‡ ููŠ .data ูƒุจูŠุฑ ูˆู‡ูƒุฐุง ู…ุน ุจู‚ูŠุช ุงู„ section ูˆุทุจุนุง ุจูŠุชุฌู…ุนูˆุง ูˆุจูŠุชุญุทูˆุง ุนู† ุงู„ physical address ุจุชุงุนู‡ู… ุงู„ุญู‚ูŠู‚ูŠ ุจู‚ู‰ ุงู„ู„ู‰ ู‡ูŠู†ุฒู„ูˆุง ููŠู‡ ููŠ ุงู„ูู„ุงุด ุจุชุงุนุช ุงู„ู…ูŠูƒุฑูˆูƒู†ุชุฑูˆู„ุฑ ูˆูƒุฏุง ุฎู„ุงุต ุงู„ูุงูŠู„ ุงุชุญูˆู„ ู…ู† relatable file ู„ locatable file ู„ุงู† ุงุชุญุท ูˆุงุชู…ุงุจ ู„ู„ุงุฏุฑูŠุณูŠุฒ ุงู„ุญู‚ูŠู‚ูŠุฉ ุจุชุงุนุช ุงู„ุชุงุฑุฌุช ุจูˆุฑุฏ ุงู„ู„ู‰ ู‡ูŠู†ุฒู„ ุนู„ูŠู‡ุง.


๐Ÿ‘-๐’๐ž๐œ๐ญ๐ข๐จ๐ง ๐‹๐จ๐œ๐š๐ญ๐ข๐จ๐ง

1-Each section is given an absolute address in memory. (Rom/Ram).

๐Ÿ’-๐ƒ๐š๐ญ๐š ๐ข๐ง๐ข๐ญ๐ข๐š๐ฅ๐ข๐ณ๐š๐ญ๐ข๐จ๐ง

1-Any initialized data is stored in non volatile memory
2-On startup non-const data must be copied to RAM.
3-Each initialized section by copying is divided into two sections , one for ROM(shadow data section) and other for RAM.
--ู‡ู†ุง ู„ูˆ ุงูŠ variables ู…ุนู…ูˆู„ ู„ูŠู‡ุง installation ูู„ุงุฒู… ุงู„ initialization ุฏู‡ ุจูŠุชุงุฎุฏ ูŠุชุญุท ููŠ ุงู„ู…ูŠู…ูˆุฑูŠ ูˆูŠุชุงุฎุฏ ู…ู†ู‡ุง ูƒูˆุจูŠ ููŠ ุงู„ ram ุนุดุงู† ู‡ูŠุชุนุฏู„ ุนู„ูŠู‡ุง At run time (ู„ูˆ ู‡ูŠ ู…ุด const ุทุจุนุง) ุจุญูŠุซ ุงู† ู„ูˆ ูุตู„ุช ุงู„ุจุงูˆุฑ ุนู† ุงู„ุจูˆุฑุฏู‡ ู„ู…ุง ุชูŠุฌูŠ ุชู‚ูˆู… ุชู‚ูˆู… ุจุงู„ Default values ูˆุฏูŠ ุงู„ู„ู‰ ู‡ุชูƒูˆู† ู…ุชุฎุฒู†ู‡ ููŠ ุงู„ Rom.
--ุงู„ุฏุงุชุง ุงู„ู„ู‰ ู‡ุชูƒูˆู† ูƒ default ููŠ ุงู„ rom ุฏูŠ ูˆู‡ุชุชู†ู‚ู„ ููŠ ุงู„ ram ู…ู† ุงู„ startup code ู„ู„ ram ุจูŠูƒูˆู† ู„ูŠู‡ุง ุณูƒุดู†ูŠู† ูˆุงุญุฏ ุงุณู…ู‡ ุงู„ Shadow ูˆุฏู‡ ุงู„ู„ู‰ ููŠ ุงู„ rom ูˆูˆุงุญุฏ Actual section ูˆุฏู‡ ุงู„ุฌุฒุก ุงู„ู„ู‰ ุงุชู†ู‚ู„ ุงูˆ ุงุชูƒุฑูŠุช ููŠ ุงู„ ram.

/*********************/

-ุงู„ู ุงู„ู ุงู„ู ู…ุจุฑูˆูƒ ุฎู„ุตู†ุง ุงู„ุญู…ุฏ ู„ู„ู‡ ุชุนุฑู ูŠุง ุญุณู† ุงู†ุช ู„ูˆ ูˆุตู„ุช ู„ุญุฏ ู‡ู†ุง ุŸ ๐Ÿ˜‚๐Ÿ˜‚โค๏ธโค๏ธ
ูุงู†ุช ุญุงุฌุชูŠู† ูŠุง ุญุณู† ูŠุง ุจุชุญุจู†ูŠ ู‚ูˆูŠ ุนุดุงู† ุชุฑุถูŠ ุชู‚ุฑุง ูƒู„ ุฏู‡ ูŠุง ุจุชุญุจ ุงู„ุงู…ุจูŠุฏูŠุฏ ูˆููŠ ุงู„ุญุงู„ุชูŠู† ุฏูˆู„ ุงู†ุง ุจุญุจูƒ ุฌุฏุง ูŠุง ุญุณู† ูˆุงู„ู„ู‡. โค๏ธโค๏ธโค๏ธ

---ุจูƒุฏุง ุงู„ุญู…ุฏู„ู„ู‡ ู†ูƒูˆู† ุฌุงูˆุจู†ุง ุนู„ูŠ ุงู„ุณุคุงู„ ุจุชุงุนู†ุง ูˆู…ุนู„ุด ู„ูˆ ุจุฏุฎู„ ููŠ ุชูุงุตูŠู„ ูˆู„ูƒู† ุจุจู‚ูŠ ุนุงูŠุฒ ุงุนุฑููƒ ุงู„ุตูˆุฑุฉ ูƒุงู…ู„ุฉ ุนุดุงู† ุงู„ู…ูˆุถูˆุน ูŠุซุจุช ูˆุชูู‡ู…ู‡ ุจุดูƒู„ ุนู…ูŠู‚.
---ูƒู…ุงู† ู‡ุชู„ุงู‚ูŠ ูƒู„ ุงู„ุจูˆุณุชุณ ุงู„ู„ูŠ ู‚ุจู„ ูƒุฏุง ุนู„ูŠ ุงู„ู‡ุดุชุงุฌ ุฏู‡ ุณูˆุงุก ู‡ู†ุง ุงูˆ ุนู„ูŠ ุงู„ููŠุณ.
---ูˆุทุจุนุง ู„ูˆ ูˆุตู„ุช ู„ู‡ู†ุง ู…ุชู†ุณุงุด ุชุฏุนูŠู„ูŠ + ุงู†ุง ู‡ุจู‚ู‰ ุณุนูŠุฏ ุฌุฏุง ู„ูˆ ุงู†ุช ูˆุตู„ุช ู„ู‡ู†ุง ๐Ÿ˜‚๐Ÿ˜‚โค๏ธโค๏ธ
/****************************/

23/11/2024

๐–๐ก๐š๐ญ ๐ข๐ฌ ๐ญ๐ก๐ž ๐’๐๐ˆ ๐ฉ๐ซ๐จ๐ญ๐จ๐œ๐จ๐ฅ? ๐‡๐จ๐ฐ ๐๐จ๐ž๐ฌ ๐ข๐ญ ๐ฐ๐จ๐ซ๐ค? ๐–๐ก๐š๐ญ ๐š๐ซ๐ž ๐ก๐ข๐ฌ ๐š๐๐ฏ๐š๐ง๐ญ๐š๐ ๐ž๐ฌ ๐ซ๐š๐ญ๐ก๐ž๐ซ ๐ญ๐ก๐š๐ง ๐”๐€๐‘๐“ ๐จ๐ซ ๐ˆ๐Ÿ๐‚ ?๐๐ข๐ฌ๐š๐๐ฏ๐š๐ง๐ญ๐š๐ ๐ž๐ฌ?๐–๐ก๐š๐ญ ๐ข๐ฌ ๐๐”๐€๐ƒ ๐’๐๐ˆ ? ๐–๐ก๐ฒ ๐ง๐จ๐ญ ๐ฎ๐ฌ๐ž ๐ข๐ญ ๐ญ๐จ ๐œ๐จ๐ง๐ง๐ž๐œ๐ญ ๐ญ๐ฐ๐จ ๐„๐‚๐”๐ฌ ๐ข๐ง ๐ญ๐ก๐ž ๐ฏ๐ž๐ก๐ข๐œ๐ฅ๐ž?
--ูŠุนู†ูŠ ุงูŠู‡ SPI ุŸ ูˆุจูŠุดุชุบู„ ุงุฐุงูŠ ุŸ
-ูˆุงูŠู‡ ู‡ูŠ ุงู„ configurations ุจุชุงุนุชู‡ ุŸ
-ูˆุฐุงูŠ ุงู„ Master ูŠุญุฏุฏ ุงู„ device ุงูˆ ุงู„ slave ุงู„ู„ูŠ ู‡ูˆ ุนุงูŠุฒ ูŠุจุนุชู„ู‡ ุนู„ูŠ ุงู„ bus
--,ุงูŠู‡ ุงู„ุดุฑูˆุท ุนุดุงู† ุงู„ Slave ูŠุจุฏุฃ ูŠุณุชู‚ุจู„ data ู…ู† ุงู„ master ุŸ
-ุจุงุณุชุฎุฏู…ู‡ ููŠ ุงูŠู‡ ุŸ
--ูŠูุฑู‚ ุงูŠู‡ ุนู† ุงู„ UART ุŸ
--ุงู…ุชูŠ ุงุดุชุบู„ ุจูŠู‡ ุงูˆ ู„ูŠู‡ ู…ู…ูƒู† ุงุฎุชุงุฑู‡ ุจุฏู„ ุงู„ UART ุงูˆ ุงู„ I2C ุŸ -ุงูŠู‡ ุงู„ advantages ุงู„ู„ูŠ ุจูŠุชู…ูŠุฒ ุจูŠู‡ุง ู‡ูˆ ุนู†ู‡ู… ุŸ
-ุงูŠู‡ ุงู„ disadvantages ุจุชุงุนุชู‡ ุŸ
--ูŠุนู†ูŠ ุงูŠู‡ QUAD SPI ุŸ
--ู„ูŠู‡ ุนู…ุฑูŠ ู…ู„ุงู‚ูŠ ุงุชู†ูŠู† ECUs ุงูˆ ุจูˆุฑุฏุชูŠู† ููŠ ุงู„ุนุฑุจูŠุฉ ู…ุชูˆุตู„ูŠู† ุจ SPI bus ุŸ
--ุงุฐุงูŠ ู†ุฎู„ูŠ ุงู„ Slave ูŠุนุฑู ูŠุจุนุช ุฏุงุชุง ู„ู„ Master ุจุงู„ุฑุบู… ุงู† ุงู„ Master ุฏู„ูˆู‚ุช ู…ูƒู†ุด ุจูŠูƒู„ู… ุงู„ slave ุจุงู„ุชุงู„ูŠ ู…ุด ุจูŠ generate ู„ูŠู‡ clock ุฏู„ูˆู‚ุช ุŸ

/**********************/

๐–๐ก๐š๐ญ ๐ข๐ฌ ๐’๐๐ˆ ๐ฉ๐ซ๐จ๐ญ๐จ๐œ๐จ๐ฅ?
SPI is a common communication protocol used by many different devices. For example, SD card reader modules, RFID card reader modules, and 2.4 GHz wireless transmitter/receivers all use SPI to communicate with microcontrollers.

One unique benefit of SPI is the fact that data can be transferred without interruption. Any number of bits can be sent or received in a continuous stream. With I2C and UART, data is sent in packets, limited to a specific number of bits. Start and stop conditions define the beginning and end of each packet, so the data is interrupted during transmission.

-- SPI (Serial peripheral Interface)
-- SPI is a serial protocol
-- SPI bus was originally started by Motorola.
--synchronous data transfer

--Full-duplex
--Single Master / multi slave
--Multiple slave devices are supported through selection with individual slave select (SS) lines.
--It can be used to communicate with a serial peripheral device like external EEPROM or with another microcontroller with an SPI interface.

-- ู‡ูˆ synchronous ูŠุนู†ูŠ ู†ู‚ู„ ุงู„ุฏุงุชุง ุจูŠุชู… ุนู† ุทุฑูŠู‚ ุงู† ููŠู‡ shared clock ุจูŠู† ุงู„ master ูˆุงู„ slave.
--ูƒู…ุงู† ู‡ูˆ full duplex ู…ุนู†ูŠ ุงู†ู‡ full duplex ูŠุนู†ูŠ ุนู†ุฏู‡ two separate line ูˆุงุญุฏ ูŠุจุนุช ุนู„ูŠู‡ ูˆูˆุงุญุฏ ุชุงู†ูŠ ูŠุณุชู‚ุจู„ ุนู„ูŠู‡ ูƒู…ุงู† ุจู…ุง ุงู†ู‡ full ูู‡ูˆ ูŠู‚ุฏุฑ ูŠุดุชุบู„ half duplex ูˆู‡ูˆ ุงู†ู‡ ูŠู‚ุฏุฑ ูŠุจุนุช ูˆูŠุณุชู‚ุจู„ ุนู„ูŠ ู†ู‚ุณ ุงู„ wire ูˆุฏู‡ ุงู†ุช ุชู‚ุฏุฑ ุชุญุฏุฏู‡ ูˆุงู†ุช ุจุชุนู…ู„ู‡ initialization.
--ูƒู…ุงู† ู‡ูˆ single master/ multi slave
ูŠุนู†ูŠ ู‡ูˆ master ูˆุงุญุฏ ุงู„ู„ูŠ ุจูŠูƒูˆู† ุนู„ูŠ ุงู„ bus ูŠุง ุญุณู† ูˆ ุญุท ุฒูŠ ู…ุชุญุท ู…ู† ุงู„ slaves.
--ู…ุนู„ุด ุจุณ ู‡ูˆ ูŠุนู†ูŠ ุงูŠู‡ master ููŠ ุงู„ู…ูˆู‚ู ุฏู‡ ุŸ
--ุจุต ูŠุง ุญุณู† ู…ุด ู‚ูˆู„ู†ุง ุงู† ุงู„ SPI ู‡ูˆ synchronous ุŸ ูŠุนู†ูŠ ููŠู‡ clock ุจูŠุญุตู„ ู„ูŠู‡ุง share ุจูŠู† ุงู„ Master ูˆุงู„ slave ุตุญ ! ุงู‡
ุทูŠุจ ู…ูŠู† ุจู‚ูŠ ุงู„ู„ูŠ ุจูŠุนู…ู„ generation ู„ู„ clock ุฏูŠ ุŸ
ู…ูŠู† ูŠุจุฏุฃ ุงู„ clock ูˆูŠู†ุฒู„ ุงู„ slave select ุนุดุงู† ูŠุญุฏุฏ ู‡ูˆ ุนุงูŠุฒ ูŠูƒู„ู… ุงู†ูŠ slave ุŸ ูˆู…ูŠู† ุงู„ู„ูŠ ุจูŠู‚ูˆู„ ูƒูุงูŠู‡ ู†ู‚ู„ ุฏุงุชุง ู„ุญุฏ ูƒุฏุง ูˆูŠุฌูŠ ูุงุตู„ ุงู„ clock ?
ุงู„ู„ูŠ ุจูŠุนู…ู„ ูƒู„ ุฏู‡ ู‡ูˆ ุงู„ master ูŠุง ุญุณู†
ูˆู„ุฐู„ูƒ ู†ูู‡ู… ุงู† ุงู„ slave ู…ูŠู‚ุฏุฑุด ูŠู‚ุฑุฑ ุงู†ู‡ ูŠุจุนุช ุฏุงุชุง ู…ู† ุนู†ุฏู‡ ู„ู„ master ู„ุง ู…ูŠู†ูุนุด ูŠุนู…ู„ ูƒุฏุง ุทุจุนุง
ู„ูŠู‡ ุŸ
ู…ู…ุง ู‚ูˆู„ุช ููˆู‚ ูŠุง ุญุณู† ุงู„ spi ู‡ูˆ synchronous ูŠุนู†ูŠ ุนุดุงู† ุงู„ุฏุงุชุง ุชุชู†ู‚ู„ ุจูŠุญุตู„ share ู„ู„ clock ุจูŠู† ุงู„ master ูˆุงู„ slave ูˆู‚ูˆู„ู†ุง ู…ู† ุฎุตุงุฆุต ุงู† ุฏู‡ ุงุณู…ู‡ master ู‡ูˆ ุงู† ู‡ูˆ ุงู„ู„ูŠ ุจูŠุนู…ู„ generation ู„ู„ clock ุงุฐุงูŠ ุงู† ู…ูŠู†ูุนุด ุงู„ slave ูŠุจุนุช ุฏุงุชุง ู…ู† ู†ูุณู‡ ูƒุฏุง ู„ู„ master ู„ุง ู„ุงุฒู… ุงู„ master ู‡ูˆ ุงู„ู„ูŠ ูŠุฌูŠ ูŠุนู…ู„ generation ู„ู„ clock ูˆูŠุทู„ุจ ู‡ูˆ ุงู„ุฏุงุชุง ุฏูŠ ู…ู†ู‡ ุจู†ูุณู‡
ูˆู‡ู†ุดูˆู ุชุญุช ุดูˆูŠู‡ ุงู„ุญุชู‡ ุฏูŠ ุฎุทุฑ ููŠ ุงูŠู‡.

/**********************/

๐‡๐จ๐ฐ ๐๐จ๐ž๐ฌ ๐ญ๐ก๐ž ๐’๐๐ˆ ๐ฉ๐ซ๐จ๐ญ๐จ๐œ๐จ๐ฅ ๐š๐ง๐ ๐ฉ๐ž๐ซ๐ข๐ฉ๐ก๐ž๐ซ๐š๐ฅ ๐ฐ๐จ๐ซ๐ค ?
--SPI consists of two shift registers, one in the master and the other in the slave side.
--Also, there is a clock generator in the master side that generates the clock for the shift registers.
--ุงู„ SPI peripheral ููŠ ูƒู„ micro ู‡ุชู„ุงู‚ูŠ ููŠู‡ shift register ..ุงู„ master ู‡ูŠูƒูˆู† ููŠู‡ ูˆุงุญุฏ ู‡ูŠุญุท ููŠู‡ุง ุงู„ data ุงู„ู„ู‰ ู‡ูˆ ุนุงูŠุฒ ูŠุจุนุชู‡ุง ูˆุงู„ Slave ู‡ูŠุญุท ููŠู‡ ุงู„ุฏุงุชุง ุงู„ู„ู‰ ู‡ูˆ ู‡ูŠุณุชู‚ุจู„ู‡ุง ุงูˆ ุงู„ุนูƒุณ.
--ูƒู…ุงู† ู…ู† ุฎูˆุงุต ุงู„ master ุฃู† ู‡ูˆ ุงู„ู„ู‰ ุจูŠุนู…ู„ generation ู„ู„ clock ูˆุจูŠุจุนุชู‡ุง ุนู† ุทุฑูŠู‚ ุงู„ clk wire ู„ุจู‚ูŠุช ุงู„ Slaves ุงูˆ ุชุญุฏูŠุฏุง ุงู„ Slave ุงู„ู„ู‰ ู‡ูˆ ู‡ูŠู†ุฒู„ ุงู„ Slave select ุจุชุงุนุชู‡.

--The serial-out pin of the master shift register is connected to the serial-in pin of the
slave shift register by MOSI (Master Out Slave In).
--The serial-in pin of the master shift register is connected to the serial-out pin of the
slave shift register by MISO (Master In Slave Out).


--ุงู„ SPI ู‡ูˆ ุงูƒุชุฑ serial protocol ุจูŠุงุฎุฏ ุนุฏุฏ pins ...ุทุจ ุงูŠู‡ ู‡ู…ุง ุงู„ pins ุจุชุงุนุช ุงู„ SPI ุŸ
1-MOSI (Master Out Slave Input.)
--ูˆุฏูŠ ุงู„ PIN ุงู„ู„ูŠ ุงู„ Master ุจูŠุจุนุช ุนู„ูŠู‡ุง ุงู„ุฏุงุชุง (out) ูˆุจูŠุณุชู‚ุจู„ ุนู„ูŠู‡ุง ุงู„ Slave (input).
2-MISO(Master Input Slave Out)
--ูˆุฏูŠ ุงู„ PIN ุงู„ู„ูŠ ุงู„ Master ุจูŠุณุชู‚ุจู„ ุนู„ูŠู‡ุง ุงู„ุฏุงุชุง (Input) ูˆูŠุจุนุช ุนู„ูŠู‡ุง ุงู„ SLAVE (out).
3-Slave select
--The master determines which chip it is talking to by the CS lines.
4-CLK
The clock signal synchronizes the output of data bits from the master to the sampling of bits by the slave. One bit of data is transferred in each clock cycle, so the speed of data transfer is determined by the frequency of the clock signal. SPI communication is always initiated by the master since the master configures and generates the clock signal.
--The master clock generator provides a clock to the shift registers in both the master and slave.
--SPI master provides clock signal (SCLK) to SPI slaves.
--ุฏูŠ ุจู‚ูŠ ูŠุง ุญุณู† ุงู„ pin ุงู„ุฑุงุจุนู‡ ุงู„ู„ูŠ ู‚ูˆู„ุชู„ูƒ ุนู„ูŠู‡ุง ุจูŠุญุตู„ generation ู…ู† ุงู„ Master ู„ู„ clock ุนู„ูŠู‡ุง.

--The clock input of the shift registers can be falling- or rising-edge triggered.
Shift registers are 8 bits long. So after 8 clock pulses, the contents of the two shift registers are interchanged.
--When the master wants to send a byte of data, it places the byte in its shift register and generates 8 clock pulses.
--After 8 clock pulses, the byte is transmitted to the other shift register.
--When the master wants to receive a byte of data, the slave side should place the byte in its shift register, and after 8 clock pulses the data will be received by the master shift register.
--ุทูŠุจ ุงู„ SPI ู‡ูˆ frameless ูˆู‡ู†ุชูƒู„ู… ููŠ ุฏูŠ ุชุญุช ุดูˆูŠู‡ ูˆู„ูƒู† ุจู…ุง ุงู†ู‡ Frameless ููƒู„ ุงู„ู„ู‰ ุจูŠุชุจุนุช ุนู„ูŠ ุงู„ Wire ู‡ูˆ ุฏุงุชุง ูุนู„ูŠู‡ ุจุณ ู…ููŠุด ุงูŠ bits ุชุงู†ูŠู‡ ุจุชุชุจุนุช ู…ุด ู…ู† ุถู…ู† ุงู„ุฏุงุชุง ูˆู„ุฐู„ูƒ ู‡ุชู„ุงู‚ู‰ ุงู†ู‡ ุจุนุฏ 8 cycles ู…ู† ู‡ูŠูƒูˆู† ุจุนุช 1 byte ุงูˆ ุงุณุชู‚ุจู„ 1 byte.
--It must be noted that SPI is full duplex, meaning that it sends and receives data at the same time.
--For the slaves that are not being talked to, the data output goes to a Hi Z state.

-- ุงู„ููƒุฑู‡ ุจู‚ูŠ ูŠุง ุญุณู† ููŠ ุงูŠู‡ ุŸ
ู…ุด ู‚ูˆู„ู†ุง ุงู† ุงู„ SPI ู‡ูˆ single master/ multi slave
ุทูŠุจ ุฏู„ูˆู‚ุช ุงู„ Master ู„ู…ุง ูŠุฌูŠ ูŠุจุนุช ุงู„ data ุงุฐุงูŠ ูŠุญุฏุฏ ู‡ูˆ ุนุงูŠุฒ ูŠุจุนุชู‡ุง ู„ Slave 0 ูˆู„ุง 1 ูˆู„ุง 2 ูˆู„ุง...
ู…ู‡ูˆ ุงูƒูŠุฏ ู…ุด ู‡ูŠุนู…ู„ broadcast ูˆูŠุจุนุช ู„ู„ูƒู„ ู‡ูˆ ุงูƒูŠุฏ ุงู„ Master
ุนุงูŠุฒ ู„ู…ุง ูŠุฌูŠ ูŠุจุนุช ูŠูƒู„ู… slave ู…ุนูŠู† ู…ูˆุฌูˆุฏ ุนู„ูŠ ุงู„ bus
ูŠุญุฏุฏ ุงู„ slave ุฏู‡ ุจู‚ูŠ ุงุฐุงูŠ ุŸ
ู„ุงู† ู„ูˆ ุชุงุฎุฏ ุจุงู„ูƒ ุงู„ mosi ูˆุงู„ miso ุทุงู„ุนูŠู† ู…ุชูˆุตู„ูŠู† ุจูƒู„ ุงู„ slaves ุงู„ู„ูŠ ุนู„ูŠ ุงู„ bus ูุงู†ุง ุนุงูŠุฒ factor ุจู‚ูŠ ูŠุญูƒู… ุงู„ master ู‡ูŠูƒู„ู… ู…ูŠู†!
ุฏู‡ ูŠุง ุญุณู† ุนู† ุทุฑูŠู‚ ุงู„ pin ุงู„ุชุงู„ุชู‡ ูˆู‡ูŠ ุงู„ Slave Select ุงูˆ ุงู„ Chip Select ุงุฐุงูŠ ูŠุนู†ูŠ
ุจุต ูŠุง ุญุณู† ุงู„ Master ุนุดุงู† ูŠุจุนุช ุฏุงุชุง ู„ุงุฒู… ูŠุญู‚ู‚ ุดุฑุทูŠู† ุงู„ุงูˆู„..ุงูŠู‡ ู‡ู…ุง ุŸ

๐Ÿ-๐Œ๐š๐ค๐ž ๐ญ๐ก๐ž ๐’๐ฅ๐š๐ฏ๐ž ๐’๐ž๐ฅ๐ž๐œ๐ญ ๐ฅ๐จ๐ฐ ๐Ÿ๐จ๐ซ ๐ญ๐ก๐ž ๐ฌ๐ฅ๐š๐ฏ๐ž ๐–๐ก๐ข๐œ๐ก ๐ข๐ญ ๐ฐ๐š๐ง๐ญ ๐ฌ๐ž๐ง๐ ๐ญ๐ก๐ž ๐๐š๐ญ๐š ๐ญ๐จ ๐ข๐ญ.
๐Ÿ-๐’๐ญ๐š๐ซ๐ญ ๐ญ๐ก๐ž ๐œ๐ฅ๐จ๐œ๐ค ๐ ๐ž๐ง๐ž๐ซ๐š๐ญ๐ข๐จ๐ง ๐จ๐ง ๐ญ๐ก๐ž ๐‚๐‹๐Š ๐ฉ๐ข๐ง

ุฏูˆู„ ุงู„ุดุฑุทูŠู† ูŠุง ุญุณู† :
1- ุงู†ูƒ ุชู†ุฒู„ ุงู„ slave select ุจุชุงุนุช ุงู„ slave ุงู„ู„ูŠ ุงู†ุช ุนุงูŠุฒ ุชูƒู„ู…ู‡ ุชู†ุฒู„ู‡ุง ู„ low
ูŠุนู†ูŠ ุงู„ slave select ุฏูŠ ู…ู†ู‡ุง ุงู†ุช ุจุชุญุฏุฏ ุงู†ุช ุนุงูŠุฒ ุชูƒู„ู… ู…ูŠู† ูˆู‡ุชู„ุงู‚ูŠ ุงู† ุจุนุฏุฏ ุงู„ Slaves ุงู„ู„ูŠ ู…ูˆุฌูˆุฏู‡ ุนู„ูŠ ุงู„ bus ู‡ุชู„ุงู‚ูŠ ุนุฏุฏ pins ุทุงู„ุนู‡ ู…ู† ุงู„ master ุฑุงูŠุญู‡ ู„ู„ slaves ูˆุฐู„ูƒ ู„ู…ุง ุญุฏ ูŠุณุฃู„ูƒ ุงู„ spi ุจูŠุงุฎุฏ ูƒุงู… pin ู‡ุชู‚ูˆู„ 3+ n
ุญูŠุซ ุงู† ุงู„ n : ู‡ูŠ ุนุฏุฏ ุงู„ Slaves ุงู„ู„ูŠ ู…ูˆุฌูˆุฏู‡ ุนู„ูŠ ุงู„ bus ูˆู„ุฐู„ูƒ ู‡ุชู„ุงู‚ูŠ ู…ูƒุชูˆุจ ุงู† ุงู„ spi ูŠู‚ุฏุฑ ูŠุชูˆุตู„ ุจุนุฏุฏ ู„ุงู†ู‡ุงุฆูŠ ู…ู† ุงู„ slaves ุนู„ูŠ ุงู„ bus ูˆุฏู‡ ู„ุงู† ูƒู„ ุงู„ู„ูŠ slave ุนุงูŠุฒู‡ ู…ู†ูƒ ู‡ูŠ ุงู„ slave select ุฏูŠ ูŠุจู‚ูŠ ุจุนุฏุฏ ุงู„ slaves ู‡ู†ุทู„ุน pins ูˆู„ูƒู† ู†ุธุฑูŠุง ู‡ูˆ ู…ุด ู…ุงู„ุงู†ู‡ุงูŠู‡ ูˆู„ุง ุญุงุฌู‡ ู‡ูˆ ู…ุญูƒูˆู… ุจุนุฏุฏ ุงู„ gpio pins ุงู„ู„ูŠ ุงู„ู„ูŠ ููŠ ุงู„ micro ุงู„ู„ูŠ ู…ุนุงูƒ ูˆุชุนุฑูู‡ู… ุนู„ูŠ ุงู†ู‡ู… input ูˆูŠูƒูˆู† ุงู„ default ุจุชุงุนู‡ู… ุจ high ูˆู„ู…ุง ุชูŠุฌูŠ ุชูƒู„ู… ุงู„ slave ุงู„ู„ูŠ ุงู†ุช ุนุงูŠุฒู‡ ุชูŠุฌูŠ ู…ู†ุฒู„ู‡ุง ู„ low.

ูˆุทุจุนุง ุงูŠ slave ุชุงู†ูŠ ุทูˆู„ ู… ุงู„ slave select ุจุชุงุนุชู‡ ู…ู†ุฒู„ุชุด ู„ low ูู‡ูˆ ู…ูˆุฌูˆุฏ ุนู„ูŠ ุงู„ bus ุงู‡ ูˆู„ูƒู† floating input ูŠุนู†ูŠ ุงู„ 2 wire ุจุชูˆุน ุงู„ mosi ูˆุงู„ miso ุจุงู„ู†ุณุจู‡ ู„ูŠุง Open circuit.
-ุชุฑุฏ ูˆุชู‚ูˆู„ ุทุจ ู„ูˆ ุนุงูŠุฒ ุงูˆุตู„ ุจ 20 slave ู‡ู„ ุงู„ spi ู‡ูŠูƒูˆู† ู…ูˆูุฑู„ูŠ 20 slave select ุŸ
-ู‡ู‚ูˆู„ูƒ ู„ุง ุทุจุนุง ู…ุด ู‡ูŠูƒูˆู† ู…ูˆูุฑ ูƒู„ ุฏู‡ ูƒ peripheral ูˆู„ูƒู† ุงู†ุช ุจู‚ูŠ ุจุชุฑูˆุญ ุจ ุงูŠุฏูƒ ู„ู„ pins ุจุชุงุนุช ุงู„ gpio.


2- ุงู„ุดุฑุท ุงู„ุชุงู†ูŠ ู‡ูˆ ุงู† ุงู„ Master ูŠุนู…ู„ generation ู„ู„ clock ุนู„ูŠ ุงู„ wire ุจุชุงุนู‡ุง ูŠุจู‚ูŠ ู„ู…ุง ุงู„ Master ูŠุนูˆุฒ ูŠูƒู„ู… slave ู…ุนูŠู† ู‡ูŠุฌูŠ ุนุงู…ู„ ุญุงุฌุชูŠู† ู…ุดุบู„ ุงู„ clock ูˆู…ู†ุฒู„ ุงู„ slave select ุจุชุงุนุช ุงู„ slave ุฏู‡ ู„ zero ู‡ุชู„ุงู‚ูŠ ุงู„ slave ุจุฏุง ูŠ communication ู…ุนุงู‡.
--ุทุจุนุง ุงู„ master ู„ู…ุง ุจูŠู†ุฒู„ slave select ุจุชุงุนุช ุงู„ Slave ุงู„ู„ู‰ ู‡ูˆ ุนุงูŠุฒ ูŠูƒู„ู…ู‡ ุจู‚ูŠุช ุงู„ Slaves ุฏู„ูˆู‚ุช ู‡ูŠ ุนู„ูŠ ุงู„ bus ูˆู„ูƒู† ุดุงูŠูู‡ ุงู„ MOSI / MISO ุงู†ู‡ู… high impedance ููƒุฃู†ู‡ู… open circuit

/**********************/

๐–๐ก๐š๐ญ ๐ข๐ฌ ๐ญ๐ก๐ž ๐š๐ฉ๐ฉ๐ฅ๐ข๐œ๐š๐ญ๐ข๐จ๐ง ๐›๐š๐ฌ๐ž๐ ๐จ๐ง ๐’๐๐ˆ ?
--Sensors
--LCDs
--Control Device
--Flash Memory

--ู‡ุชู„ุงู‚ูŠ ุงู† ููŠู‡ ุจุนุถ ุงู„ sensors ุงู„ interface ุจุชุงุนู‡ SPI
ุฏู‡ ุจุณุจุจ ุงู† ุงู„ SPI ุณุฑูŠุน ู„ุงู†ู‡ frameless ูˆุฏู‡ ุงุฏุงู†ูŠ ู…ูŠุฒุชูŠู† ููˆู‚ ุงู„ุนุธู…ุฉ ูˆุจูŠู…ูŠุฒูˆู‡ ุนู† ุบูŠุฑู‡ ุณูˆุงุก ุงู„ I2C ุงูˆ ุงู„ UART ุงูŠู‡ ู‡ู…ุง ุงู„ู…ูŠุฒุชูŠู† ุฏูˆู„ ุŸ
ุจุณ ู‚ูˆู„ูŠ ุงู„ุงูˆู„ ูŠุนู†ูŠ ุงูŠู‡ Frame less ูˆุงู„ู„ูŠ ุจุณุจุจู‡ุง ุงุฎุฏู†ุง ุงู„ู…ูŠุฒุชูŠู† ุฏูˆู„ ุŸ
ุจุต frame less ูŠุนู†ูŠ ุงู„ ู„ู…ุง ุจูŠุฌูŠ ูŠุจุนุช ุงู„ุฏุงุชุง ุนู„ูŠ ุงู„ wire ุจูŠุจุนุช ุฏุงุชุง ุจุณ ู…ุด ุจูŠุจุนุช ุงูŠ ุญุงุฌู‡ ุชุงู†ูŠ ู…ุด ุฒูŠ ุงู„ uart ู…ุซู„ุง ุชู„ุงู‚ูŠ ู„ุง ููŠู‡
1-Start bit
--ุงู„ RX ุจุชูƒูˆู† idle ุจ 1 ูŠุนู†ูŠ ููŠ ุงู„ูˆุถุน ุงู„ุนุงุฏูŠ ุงู†ู‡ ุจูŠุจุนุช ุจูŠูƒูˆู† ุนู„ูŠู‡ุง logic high ุงูˆู„ ู… ุงู„ู…ูŠูƒุฑูˆ ุฑู‚ู… ูˆุงุญุฏ ูŠุฌูŠ ูŠุจุนุช ู„ู„ู…ูŠูƒุฑูˆ ุงู„ุชุงู†ูŠ ุนุดุงู† ูŠุนุฑูู‡ ุงู†ู‡ ู‡ูŠุจุฏุฃ ูŠุจุนุช ุงู‡ูˆ.

2-data field
ุงู„ Data field ููŠ ุงู„ UART ุจูŠุงุฎุฏ ู…ู† 5 ู„ 9 bit ููŠ ุงู„ field ุฏู‡ ุจูŠุชุญุท ุงู„ุฏุงุชุง ุงู„ู„ู‰ ุงุญู†ุง ุนุงูŠุฒูŠู† ู†ุจุนุชู‡ุง ู…ู† ุงู„ู…ูŠูƒุฑูˆ ุงู„ุงูˆู„ ู„ู„ู…ูŠูƒุฑูˆ ุงู„ุชุงู†ูŠ

3-parity bits
--The parity bit is added to make the number of 1โ€™s even (even parity) or odd (odd parity).
--This bit can be used by the receiver to check for transmission errors.

ูุฒูŠ ู… ุงู†ุช ุดุงูŠู ุงู„uart ุจูŠุชูƒูˆู† ู…ู† frame ุงู‡ูˆ ูˆูƒุฐู„ูƒ ุงู„ i2c
--ูƒูˆู† ุงู† ุงู„ SPI ู‡ูˆ Frameless ูู‡ูˆ ุงุฏุงูƒ ู…ูŠุฒุชูŠู† ุงู„ู„ูŠ ู‚ูˆู„ุช ุนู„ูŠู‡ู… ููˆู‚:
1-ุนุดุงู† ู…ููŠุด farm ููƒู„ ุงู„ bits ุงู„ู„ูŠ ุจุชุชุจุนุช ู‡ูŠ data ุจุณ ู…ููŠุด ุงูŠ bits ุชุงู†ูŠู‡ ุชุฎุต ุงู„ Frame ูุฏู‡ ุฎู„ูŠ ุงู„ throughput
ุจุณ ูŠุนู†ูŠ ุงูŠู‡ throughput

/*********************/

๐–๐ก๐š๐ญ ๐ข๐ฌ ๐ญ๐ก๐ž ๐ญ๐ก๐ซ๐จ๐ฎ๐ ๐ก๐ฉ๐ฎ๐ญ ?
--it is the effective data bit / total bits which i send
--ูŠุนู†ูŠ ุงูŠู‡ ุŸ
--ุงู„ throughput ู‡ูˆ ุงู„ุฏุงุชุง ุงู„ูุนู„ูŠู‡ ุงูˆ ุงู„ู…ู‡ู…ู‡ ุจุงู„ู†ุณุจู‡ ู„ูŠูƒ ุงู„ู„ู‰ ุงู†ุช ุนุงูŠุฒ ุชุจุนุชู‡ุง ูŠุนู†ูŠ ู„ู…ุง ุฌูŠุช ุชุจุนุช ุญุฑู ุงู„ 'A' ู…ุซู„ุง ุจุงุณุชุฎุฏุงู… ุงู„ uart ุงู„ู„ู‰ ู‡ูˆ ู‡ูŠุชู…ุซู„ ููŠ 8 bit ุจุงู„ู†ุณุจู‡ ู„ูŠูƒ ุฏูŠ ุงู„ุฏุงุชุง ุงู„ู…ู‡ู…ุฉ ูˆุฏูŠ ุงู„ู„ู‰ ุงู†ุช ุนุงูŠุฒู‡ุง ุชูˆุตู„ ูุนู„ุง
--ุจุณ ู‡ู„ ู‡ูŠ ุงุชุจุนุชุช ู„ูˆุญุฏู‡ ุŸ ู„ุง ุทุจุนุง ุฏูŠ ุงุชุญุทุช ููŠ ุงู„ fails ุจุชุงุน ุงู„ุฏุงุชุง ู„ูƒู† ุงุชุญุท ู…ุนุงู‡ุง ู ุงู„ frame ุฏุงุชุง ุชุงู†ูŠู‡ ุงู†ุง ู…ุด ู…ู‡ุชู… ุจูŠู‡ุง ุงุตู„ุง ูˆู„ูƒู† ู‡ูŠ ู„ุงุฒู… ุชุชุจุนุช ู„ุงู† ุฏู‡ ูุฑูŠู… ุงู„ uart ุฒูŠ ุงู„ start bit ูˆุงู„ parity ูˆุงู„ stop bits
--ูุงู„ throughput ุฏู‡ ุจู‚ู‰ ุงู„ุฏุงุชุง ุงู„ู„ู‰ ุงู†ุช ุนุงูŠุฒ ุชุจุนุชู‡ุง ูุนู„ุง ู…ู‚ุณูˆู…ุฉ ุนู„ูŠ ูƒู„ ุงู„ bits ุงู„ู„ู‰ ุงู†ุช ุจุชุจุนุชู‡ุง ุงู„ู„ู‰ ู‡ูŠ ุงู„ bits ุจุชุงุนุช ุงู„ุฏุงุชุง ู…ุฌู…ูˆุน ุนู„ูŠู‡ุง ุงู„ bits ุงู„ู„ู‰ ุจุชุญุท ููŠ ุงู„ frame ุบุตุจ ุนู†ูŠ.
--ู…ุซุงู„ ุนู„ูŠ ุฏู‡ ู„ูˆ ุงู†ุช ุจุชุจุนุช 8 bit ูˆุฏูˆู„ ุงู„ effective data ุจูŠุชุญุท ู…ุนุงู‡ู… ูˆุงุญุฏุฉ start ูˆุงุญุฏุฉ stop ูˆู†ู‚ูˆู„ ูŠุนู… ุงู„ parity ุจ 0 ูŠุนู†ูŠ ุงู„ 8 bit ุงุชุญุท ู…ุนุงู‡ู… 2 ุฒูŠุงุฏู‡.
--ูŠุนู†ูŠ ุงู„ throughput = 8/10 ูŠุนู†ูŠ 80% ู…ุง ุจุงู„ูƒ ุจู‚ู‰ ู„ูˆ ุญุงุทุช ุงุชู†ูŠู† parity ูˆุงุชู†ูŠู† stop ูุฃู†ุช ู‡ุชู„ุงู‚ูŠ ู†ูุณูƒ ูˆุตู„ุช ู„ 60% ู…ุซู„ุง ุงู„ throughput ูŠุนู†ูŠ ุนุดุงู† ุงู†ู‚ู„ 60000 bit ู„ุงุฒู… ุงู†ู‚ู„ ู…ุนุงู‡ู… 40000 bits ู…ุนุงู‡ู… ุนุดุงู† ุฎุงุทุฑ ุงู„ุญุงุฌ FRAME
ูุนุดุงู† ูƒุฏุง ุงู„ throughput ุจุชุงุน ุงู„ SPI 100% ู„ุงู† ุงู„ effective data ู‡ู‰ ุงู„ู„ู‰ ุจุชุชุจุนุช ุจุณ ู…ู…ุนู‡ุงุด ุญุงุฌู‡ ุชุงู†ูŠู‡.
ูˆุฏู‡ ุฎู„ุงู‡ ุณุฑูŠุน ุฌุฏุง ุจูŠูˆุตู„ ู„ 480 M bits / sec.
ุงู„ู…ูŠุฒู‡ ุงู„ุชุงู†ูŠู‡ ุงู„ู„ูŠ ุงู†ุช ุงุฎุฏุชู‡ุง ู…ู† ูƒูˆู†ู‡ frameless
2- ุงู†ูƒ ุชู‚ุฏุฑ ุชุนู…ู„ ุงู†ุช its your frame
ูŠุนู†ูŠ ุงูŠู‡ ุŸ
ููŠ ุงู„ SPI ุงู†ุช ุชู‚ุฏุฑ ุชุฑุณู… ูˆุชุญุฏุฏ ุงู†ุช frame ุฎุงุต ุจูŠูƒ ูˆุนู„ูŠ ู…ุฒุงุฌูƒ ุงู†ุช ูŠุนู†ูŠ ู…ู…ูƒู† ุชู‚ูˆู„ ู…ุซู„ุง ุงูˆู„ byte ู‡ุจุนุชู‡ ุฏู‡ ุงู„ ID ุจุชุงุน ุงู„ slave ุงูˆ ุงู„ ECU ุงู„ู„ูŠ ุนุงูŠุฒ ุงูƒู„ู…ู‡ุง ูˆุงู„ byte ุงู„ู„ูŠ ุจุนุฏู‡ ู…ุซู„ุง ุงู„ transaction ุงู„ู„ูŠ ุนุงูŠุฒ ุชุนู…ู„ู‡ read/write ูˆุงู„ู„ูŠ ุจุนุฏู‡ ู…ุซู„ุง ุงู„ data ูˆุจุนุฏ ูƒู„ data ููŠู‡ ack ูุฒูŠ ู… ุงู†ุช ุดุงูŠู ู…ูŠุฒุฉ ุงู†ู‡ frameless ุงุฏุงูƒ ู…ูŠุฒุฉ ุงู†ูƒ ุชู‚ุฏุฑ ุชุญุฏุฏ ุงูˆ ุชุนู…ู„ frame ุฎุงุต ุจูŠูƒ ุงู†ุช.

/*************************/

--ุจุณ ู…ุนู„ุด ุณุคุงู„ ู…ู†ุชุง ู„ู…ุง ู…ุจู‚ุชุด frame ุฎุณุฑุช ุงู† ูŠูƒูˆู† ุนู†ุฏูƒ parity ุงูˆ checksum ุงูˆ ุงูŠ ู†ูˆุน ู…ู† ุงู†ูˆุงุน ุงู„ check ุงู† ุญุตู„ ู…ุดูƒู„ู‡ ููŠ ุงู„ data ูˆู„ุง ู„ุง ู‡ู‚ูˆู„ูƒ ุนู†ุฏูƒ ุญู‚ ุทุจุนุง ูŠุง ุญุณู†.
ู…ู‡ูˆ ุนุดุงู† ูƒุฏุง ุงู„ SPI ู„ู…ุง ุจู†ูˆุตู„ ุญุงุฌุชูŠู† ุงูˆ ุงูƒุชุฑ ุจุจุนุถ ุจูŠูƒูˆู† ุทูˆู„ ุงู„ bus ููŠ ุญุฏูˆุฏ 10 cm ูˆุฏู‡ ุนุดุงู† ุงู†ุง ุฎุงูŠู ุงู† ุงู„ุฏุงุชุง ุชุจูˆุธ ู…ู† ุงู„ noise ูˆุงู†ุง ู…ุนู†ุฏูŠุด ู…ูŠูƒุงู†ูŠุฒู… ุงูƒุชุดู ุจูŠู‡ ูู‚ุงู„ูƒ ุฎู„ุงุต ุชูƒูˆู† ุงู„ู…ุณุงูุฉ ููŠ ุงู„ุฑูŠู†ุฌ ุฏู‡ ุนุดุงู† ุงุชุฌู†ุจ ุงู„ noise ุนู„ูŠ ู‚ุฏ ู…ู‚ุฏุฑ ูŠุนู†ูŠ
/************/
ุทูŠุจ ุจูŠุดุชุบู„ ุงุฐุงูŠ ุงูˆ ุงู„ circuit ู…ู† ุฌูˆุง ุจุชุชูƒูˆู† ู…ู† ุงูŠู‡ ?
ุจุต ูŠุง ุญุณู† ุงู„ circuit ุจุชุงุนุชู‡ simple ู‚ูˆูŠ ูŠุงุฏูˆุจ register ุนู†ุฏ ุงู„ master ูˆุฒูŠู‡ ุนู†ุฏ ุงู„ slave ูˆุงู„ุงุชู†ูŠู† ููŠู‡ู… ุฏุงุฆุฑุฉ ู„ู„ clock ุชูŠุฌูŠ ุงู†ุช ุชุญุท ุงู„ุฏุงุชุง ุงู„ู„ูŠ ุนุงูŠุฒ ุชุจุนุชู‡ุง ููŠ ุงู„ register ุจุชุงุน ุงู„ู„ูŠ ุนู†ุฏ ุงู„ master ูˆู‡ูˆ ูŠุดุชุบู„ ุจู‚ูŠ ู…ุน ูƒู„ ุงู„ clock ูƒู„ cycle ูŠุจุนุช one bit ู„ู„ู†ุงุญูŠู‡ ุงู„ุชุงู†ูŠู‡ ูˆุงู„ุชุงู†ูŠ ูŠุณุชู‚ุจู„ู‡ุง ูŠุญุทู‡ุง ููŠ ุงู„ register ุงูˆ ุงู„ buffer ุงู„ู„ูŠ ุนู†ุฏู‡ ุฏู‡.

/***********/


๐–๐ก๐š๐ญ ๐š๐ซ๐ž ๐’๐๐ˆ ๐€๐๐ฏ๐š๐ง๐ญ๐š๐ ๐ž๐ฌ?
1-SPI is frameless so ( high speed + customized frame)
2-Separate MISO and MOSI lines, so data can be sent and received at the same time
3- throughput is 100%
4- Simple circuit
5- Support Multiple slaves
6-Lower power requirement than I2C
7-No complicated slave addressing system like I2C

/***********/

๐–๐ก๐š๐ญ ๐š๐ซ๐ž ๐’๐๐ˆ ๐๐ข๐ฌ๐š๐๐ฏ๐š๐ง๐ญ๐š๐ ๐ž๐ฌ?
1- Requires more pins
2-Master must control all communications (slave can't generates transaction)
3- Separate SS line
4-No flow control
5-No acknowledgement that the data has been successfully received (I2C has this)
6-No form of error checking like the parity bit in UART.
--ุงู„ุนูŠูˆุจ ุจู‚ูŠ ูŠุง ุญุณู†
1- ุฒูŠ ู… ุงู†ุช ุดุงูŠู ุงู† ูƒู„ slave ุจูŠุญุชุงุฌ slave select pin ูŠุนู†ูŠ ุทู„ ู…ุนุฏุฏ ุงู„ slave ุฒุงุฏ ุนุฏุฏ ุงู„ pins ู‡ูŠุฒูŠุฏ ู…ุด ุฒูŠ ุงู„ i2c ุงูˆ ุงู„ can ู…ุซู„ุง ู‡ู…ุง 2 wire ูˆูƒู„ ุงู„ ECUs ุนู„ูŠู‡ ู„ุง ูƒู„ slave ุนุงูŠุฒ pin ุนุดุงู† ุชู‚ุฏุฑ ุชุญุฏุฏ ุงู†ุช ุนุงูŠุฒ ุชูƒู„ู… ู…ูŠู† ู…ู† ุฎู„ุงู„ู‡ุง.

2-ุงู„ master ู‡ูˆ ุงู„ู„ูŠ ุจูŠุฏูŠุฑ ุงูŠ ุนู…ู„ูŠุฉ ุชูˆุงุตู„ ูŠุนู†ูŠ ู‡ูˆ ุงู„ู„ูŠ ุจูŠุฑูˆุญ ูŠูƒู„ู… ุงู„ slave ุนุดุงู† ูŠุจุนุช ู„ูŠู‡ ุฏุงุชุง ุนู†ุฏู‡ ุงูˆ ูŠุฑูˆุญ ู„ู„ slave ูŠู‚ูˆู„ู‡ ุนู†ุฏูƒ ุฏุงุชุง ุŸ ู„ูˆ ุนู†ุฏูƒ ุงุจุนุช
(ุงู„ุญุชู‡ ุฏูŠ ุฎุทุฑ ุฌุงู…ุฏ ูŠุง ุญุณู† ุฑูƒุฒ ู‡ู†ุง)
ู…ุชุฎูŠู„ ุงู† ุงู„ slave ู„ูˆ ุนู†ุฏู‡ data ุนุงูŠุฒ ูŠุจุนุชู‡ุง ู„ู„ master ู…ูŠู‚ุฏุฑ ูŠุนู…ู„ ุงูŠ ุญุงุฌู‡ ุนุดุงู† ูŠุนุฑู ุงู„ Master ุงู†ู‡ ุนู†ุฏู‡ data ูˆูƒู…ุงู† ู…ูŠู‚ุฏุฑ ูŠุจุนุชู‡ุง ู„ุงู† ู‡ูˆ slave ูˆุงุญู†ุง ู‚ูˆู„ู†ุง ุงู„ู„ูŠ ุจูŠุนู…ู„ generate ู„ู„ clock ู‡ูˆ ุงู„ master ูˆู‚ูˆู„ู†ุง ุงู† ุนุดุงู† ุงุจุชุฏูŠ ุงุจุนุช ุฏุงุชุง ู„ุงุฒู… ุงุนู…ู„ ุญุงุฌุชูŠู† ุงุดุบู„ ุงู„ clock ูˆุงู†ุฒู„ ุงู„ pin ุจุชุงุนุช ุงู„ ss ู…ู† high ู„ low
ูุงู†ุช ูƒ master ู‡ุชูุถู„ ูˆุงู‚ู ู…ุญุจูˆุณ ุจุงู„ุฏุงุชุง ุงู„ู„ูŠ ู…ุนุงูƒ ุฏูŠ ู„ุญุฏ ู…ูŠุจุงู† ู„ูŠูƒ ุตุงุญุจ ูˆุงู„ master ูŠุฌูŠ ูŠู‚ูˆู„ูƒ ู„ูˆ ุนู†ุฏูƒ ุฏุงุชุง ุงุจุนุชู‡ุง

ุทุจุนุง ูŠุง ุญุณู† ู…ูŠู†ูุนุด ุชุจู‚ูŠ ููŠ critical system ูˆุชุนู…ู„ ุงู„ุญุชู‡ ุงู„ู„ูŠ ููˆู‚ ุฏูŠ ุงู† ุงู„ master ูŠูƒูˆู† ุนู†ุฏู‡ data ู…ู‡ู…ู‡ ูˆู„ุงุฒู… ุชุชุจุนุช ู„ู„ master ุฏู„ูˆู‚ุช ูˆุทุจุนุง ุงู„ slave ู…ุด ู‡ูŠุนุฑู ูˆูƒุฏุง ุงู†ุช ุดุฏูŠุช ุจู„ุณุชุฑ ุนู„ูŠ ุจูˆู‚ ุงู„ slave ูˆุงู„ุณูŠุณุชู… ู‡ูŠุฑูˆุญ ููŠ ุฏุงู‡ูŠู‡
ูŠุนู†ูŠ ู…ูŠุจู‚ุงุด ู…ุซู„ุง ุงู„ slave ุจูŠุณุชู‚ุจู„ frames ุจุชุงุนุช camera ููŠ ุงู„ุนุฑุจูŠู‡ ุจุชุญู„ู„ ุงู„ุทุฑูŠู‚ ูˆุจุนุฏูŠู† ุงู„ slave ูŠุจุนุช ุงู„data ุฏูŠ ู„ู„ master ุนู† ุทุฑูŠู‚ ุงู„ spi ูˆุงู„ master ู‡ูˆ ุงู„ู„ูŠ ูŠุงุฎุฏ ุงู„ action ู„ูˆ ุงู„ุนุฑุจูŠู‡ ู‡ุชูุฑู…ู„ ู…ุซู„ุง ุงูˆ ู‡ุชุนู…ู„ alarm ู‡ู„ ุจู‚ูŠ ูŠู†ูุน ุงู„ู„ูŠ ููˆู‚ ุฏู‡ ุŸ

--ู„ูˆ ุนู…ู„ุช ูƒุฏุง ูŠุจู‚ูŠ ุงู„ system ุจุงู„ุณู„ุงู…ู‡ ู„ุงู† ุงู„ slave ุนู†ุฏู‡ ุฏุงุชุง ู…ู‡ู…ู‡ ูˆู„ุงุฒู… ุชุชุจุนุช ุญุงู„ุง ูˆู…ุด ุนุงุฑู ู‡ูˆ ู…ุณุชู†ูŠ ุงู„ master ูŠุฌูŠ ู„ูŠู‡ ุทุจ ูˆุงู„ุญู„ ุŸ
--ุงู„ุญู„ ุงู†ูƒ ุชุชู…ุณูŠ ูŠุง ุญุณู† ูˆุชู‚ูˆู„ ูŠุง ู…ุณุง ูˆู…ุชุนู…ู„ุด ุญุงุฌู‡ ุฒูŠ ูƒุฏุง ุงุตู„ุง ู…ู† ุงู„ุงูˆู„ ูƒ design
ูŠุง ุงู…ุง ู‡ุชูƒูˆู† ุฏุงุชุง ุงู‡ ู‡ุชุชู†ู‚ู„ ู…ู† ุงู„ slave ู„ู„ master ูˆู„ูƒู† ู…ุด critical ูˆู„ุงุฒู… ุชูˆุตู„ูŠ ูˆู‚ุชูŠ ู„ุง ุนุงุฏูŠ ุงู†ู‡ุง ุชูุถู„ ู„ุญุฏ ู… ุงู„ master ูŠุจุนุช ู‡ุงุช ุงู„ุฏุงุชุง ุงู„ู„ูŠ ุนู†ุฏูƒ ุงูˆ ูŠูƒูˆู† ููŠู‡ period check ู…ู† ุงู„ master ูŠุฑูˆุญ ูŠุชุดูƒ ุนู„ูŠ ุงู„ slave ูƒู„ ูุชุฑู‡ ู„ูˆ ุนู†ุฏู‡ ุฏุงุชุง.
ู 
--ุทูŠุจ ู‡ู„ ูŠุง ุญุณู† ู„ูˆ ู…ุนุงูŠุง master ูˆุงุญุฏ ูˆ slave ูˆุงุญุฏ ู‡ู„ ููŠู‡ ุฏุงุนูŠ ุงูˆุตู„ ุงู„ุงุชู†ูŠู† slave select pins ุจุนุถ ุŸ
-- ู‡ุงุฌูŠ ุฑุงุฏุฏ ุนู„ูŠูƒ ูŠุง ุญุณู† ูˆู‚ุงูŠู„ ู…ุด ุงู„ slave select ุนุดุงู† ุงู„ master ูŠุฎุชุงุฑ ุงู„ slave ุงู„ู„ูŠ ู‡ูˆ ุนุงูŠุฒ ูŠุจุนุชู„ู‡ ุŸ ูˆู‚ูˆู„ู†ุง ููˆู‚ ุนุดุงู† ุงุจุฏุง ุงูƒู„ู… slave ู…ุนูŠู† ูุงู†ุง ุจุดุบู„ ุงู„ clk ูˆุจู†ุฒู„ ุงู„ ss ุจุชุงุนุช ุงู„ slave ุงู„ู„ูŠ ุนุงูŠุฒ ุงูƒู„ู…ู‡ ู„ low ุตุญ ุŸ ูˆุทุจุนุง ุจุดุบู„ ุงู„ CLK
ุทุจ ู… ู„ูˆ master/slave ุงุชู†ูŠู† ุจุณ ุฎู„ุงุต ุงุฎู„ูŠ ุงู„ ss ุจุชุงุนุช ุงู„ slave ุจ low ุนู„ูŠ ุทูˆู„ ูŠุนู†ูŠ ุงูˆุตู„ู‡ุง ุจ gnd ูˆูƒุฏุง ุจู‚ูŠ ุนุงู…ู„ ุงู† ุงูƒู„ู… ุงู„ slave ุฏู‡ ูˆุงู„ู„ูŠ ู…ููŠุด ุบูŠุฑู‡ ุงุตู„ุง ุจู‚ูŠ ุจูŠ depend ุนู„ูŠ ุนุงู…ู„ ูˆุงุญุฏ ุจุณ ูˆู‡ูˆ ุงู†ูƒ ูƒ master ุชุดุบู„ ุงู„ clk ุจุณ ูˆูƒุฏุง ูƒุฏุง ุงู„ุนุงู…ู„ ุงู„ุชุงู†ูŠ ุฌุงู‡ุฒ ุงุตู„ุง ู„ุงู† ู…ูˆุตู„ ุงู„ ss ุจ gnd.

/***************/

ุทูŠุจ ู…ู…ูƒู† ุงุณุชุฎุฏู… ุงู„ SPI ููŠ ุงูŠ ุŸ
--SPI with flash memory
--Most SPI flash memories have a write status register command that writes one or two bytes of data.
--To write to the status register, the SPI host first enables the slave select line for the current device. The master then outputs the appropriate instruction followed by two data bytes.

--ู‡ู†ุง ูŠุง ุญุณู† ู‡ุชู„ุงู‚ูŠู†ุง ุงุณุชุบู„ูŠู†ุง ุงู†ู‡ frameless ูˆุงู†ู†ุง ู†ู‚ุฏุฑ ู†ุนู…ู„ our own frame ูˆุจู‚ุช ู…ุซู„ุง ุงู„ flash memory ุฏูŠ ุฌุงูŠุจู‡ุง ุงูˆุตู„ู‡ุง ู…ุน ุงู„ microcontroller ู…ู† ุจุฑู‡ ุนู„ูŠ ุณุทุญ ุงู„ุจูˆุฑุฏ ู…ุซู„ุง
ูู„ู…ุง ุงูุชุญ ุงู„ datasheet ุจุชุงุนุช ุงู„ flash ุฏูŠ ู‡ู„ุงู‚ูŠ ู…ุซู„ุง ุจูŠู‚ูˆู„ูŠ ู„ูˆ ุนุงูŠุฒ ุชูƒุชุจ ุนู„ูŠ ู…ูƒุงู† ู…ุนูŠู† ููŠ ุงู„ูู„ุงุด ุฏูŠ ู‡ุชุจุนุช ุงูˆู„ ุญุงุฌู‡ instruction ุงุณู…ู‡ ูƒุฐุง ูˆู„ูŠูƒู† 0x08 ุฏู‡ ู„ู…ุง ุงู†ุช ุชุจุนุชู‡ ุงูˆู„ byte ูƒุฏุช ุงู„ูู„ุงุด ู‡ุชูู‡ู… ุงู†ูƒ ุนุงูŠุฒ ุชูƒุชุจ ุจุนุฏ ูƒุฏุง ูŠู‚ูˆู„ูƒ ู…ุซู„ุง ุงุจุนุชู„ูŠ ุงู„ address ุจุชุงุน ุงู„ู…ูƒุงู† ุงู„ู„ูŠ ุนุงูŠุฒ ุชูƒุชุจ ุนู„ูŠู‡ ุจุนุฏ ูƒุฏุง ุงุจุนุช ุงู„ุฏุงุชุง ุงู„ู„ูŠ ุนุงูŠุฒ ุชูƒุชุจู‡ุง ูุงู†ุช ู„ูˆ ุชู„ุงุญุธ ู‡ุชู„ุงู‚ูŠ ุงู†ูƒ ู‚ุฏุฑุช ุชุจู†ูŠ ุงู„ูุฑูŠู… ุจุชุงุนูƒ ุงู†ุช ุงูˆู„ ุงู…ุฑ ู…ุซู„ุง instruction ูˆุงู„ุชุงู†ูŠ address ูˆุงู„ุชุงู„ุช ุฏู‡ ุงู„ุฏุงุชุง ุงู„ู„ูŠ ุนุงูŠุฒ ุชูƒุชุจู‡ุง.
--ุทุจ ู„ูˆ ุนุงูŠุฒ ุงู‚ุฑุง ู…ู†ู‡ุง ุงู†ุง ุŸ
ู‡ุงุฌูŠ ุจุงุนุช ุงูˆู„ byte ูˆู„ุชูƒู† 0x04 ูˆุฏู‡ instruction ุงู„ูู„ุงุด ุนุงุฑูู‡ุง ุงู† ุฏู‡ ู„ูˆ ุงุชุจุนุช ููŠ ุงูˆู„ byte ูŠุจู‚ูŠ ุฏู‡ ุงู…ุฑ ุงู„ read ูˆุทุจุนุง ุงู†ุช ู…ุดุบู„ ุงู„ clk ูˆู…ู†ุฒู„ ุงู„ slave select ู„ low ู‡ุชุจุต ุนู„ูŠ ุงู„ wire ุงู„ุชุงู†ูŠ ุงู„ู„ูŠ ู‡ูˆ MiSO ู‡ุชู„ุงู‚ูŠ ุจุนุช ู„ูŠูƒ ุงู„ุฏุงุชุง ุงู„ู„ูŠ ุงู†ุช ูƒู†ุช ุนุงูŠุฒู‡ุง.
/***********/
ุทุจุนุง ูŠุง ุญุณู† ู„ูˆ ู‡ุชุดุชุบู„ ุจ mode ุงู„ half duplex ูุงู†ุช ู‡ุชุดุชุบู„ ุจ 3 pins ุจุณ ุงู„
CLK
MOSI --- MISO
SS
GND
ูˆููŠ ุงู„ุญุงู„ู‡ ุฏูŠ ุงู†ุช ุจุชูˆุตู„ ุงู„ miso ุจุงู„ mosi ุจุจุนุถ
ู‡ู†ุง ุงู‡ ุงู†ุช ู‚ู„ู„ุช ุนุฏุฏ ุงู„ pins ุจุณ ุงู„ throughput ู‚ู„ ู„ุงู†ูƒ ุจู‚ูŠุช ุจุชุจุนุช ูˆุชุณุชู‚ุจู„ ุนู„ูŠ ู†ูุณ ุงู„ wire ูˆู…ุด ููŠ ู†ูุณ ุงู„ูˆู‚ุช ูƒู…ุงู†

/************/

๐–๐ก๐š๐ญ ๐ข๐ฌ ๐๐”๐€๐ƒ ๐’๐๐ˆ ?
--Multi I/O variants such as dual I/O and quad I/O add additional data lines to the standard for increased throughput. This performance increase enables random access and direct program ex*****on from flash memory (execute-in-place).
--A multi I/O SPI device is capable of supporting increased bandwidth or throughput from a single device.


--ุฌู‡ ู‚ุงู„ูƒ ูŠุง ุญุณู† ุงูŠู‡ ู…ุชูŠุฌูŠ ู†ุฒูˆุฏ ุนุฏุฏ ุงู„ pins ุงู„ู„ูŠ ู…ู…ูƒู† ุงุจุนุช ูˆุงุณุชู‚ุจู„ ู…ู† ุนู„ูŠู‡ุง
ูŠุนู†ูŠ ููŠ ุงู„ half duplex ุจุฏู„ ู…ูŠุจู‚ูŠ ุนู†ุฏูŠ pin ูˆุงุญุฏ ุจุณ ุงุจุนุช ุงูˆ ุงุณุชู‚ุจู„ ู…ู† ุนู„ูŠู‡ุง(ุจุณ ู…ุด ููŠ ู†ูุณ ุงู„ูˆู‚ุช ุทุจุนุง)
ู‚ุงู„ูƒ ุทุจ ู…ุฎู„ูŠู‡ู… ุงุฑุจุนู‡ ูŠู‚ุฏุฑูˆุง ูŠุจุนุชูˆุง ูˆูŠุณุชู‚ุจูˆู„ูˆุง(ุจุณ ุทุจุนุง ู…ุด ููŠ ู†ูุณ ุงู„ูˆู‚ุช ู„ุงู†ู‡ half)
ูˆุนู…ู„ูˆุง 4 pins ุงุจุนุช ูˆุงุณุชู‚ุจู„ ู…ู† ุนู„ูŠู‡ู… ูˆุงู‚ุฏุฑ ุงุณุชุฎุฏู… ุฏู‡ ู…ุน ุจุนุถ ุงู„ flash memory ุจูŠูƒูˆู† ุงู„ุงู†ุชุฑููŠุณ ุจุชุงุนู‡ุง ูƒุฏุง ูˆูƒุฏุง ุจู‚ูŠ ุนู†ุฏูŠ 4 shift register ูŠุนู†ูŠ ุงู‚ุฏุฑ ุงู‚ุฑุง ุงูˆ ุงูƒุชุจ ููŠ ุงุฑุจุน ุงู…ุงูƒู† ู…ุฎุชู„ูู‡ ููŠ ุงู„ูู„ุงุด ุฏูŠ.

--ูƒู…ุงู† ู‡ุชู„ุงู‚ูŠ dual SPI
--ู†ูุณ ุงู„ู„ูŠ ู‚ูˆู„ู†ุงู‡ ููŠ ุงู„ quad ุจุณ ุฏู‡ ู„ูŠู‡ 2 pins ุจุณ
MOSI
MISO
ูŠู‚ุฏุฑ ูŠุจุนุช ูˆูŠุณุชู‚ุจู„ ู…ู† ุนู„ูŠู‡ู… ุจุณ ุงูƒูŠุฏ ูƒู„ pin ู…ุด ู‡ุชุจุนุช ูˆุชุณุชู‚ุจู„ ููŠ ู†ูุณ ุงู„ูˆู‚ุช ู„ุง.

/**************/

ุทูŠุจ ููŠู‡ ุณุคุงู„ ู‡ู†ุง ู„ูŠู‡ ู…ุซู„ุง ุนู…ุฑูƒ ู…ุชู„ุงู‚ูŠ ุงุชู†ูŠู† ECUs ููŠ ุงู„ุนุฑุจูŠู‡ ู…ุชูˆุตู„ูŠู† ุจุงู„ SPI ุŸ
--ู„ ูฃ ุงุณุจุงุจ
1-ู…ุด ุงุญู†ุง ู‚ูˆู„ู†ุง ุงู†ู‡ frameless !
ูู‡ูˆ ูƒุฏุง ู…ููŠู‡ุด ุงูŠ Field ู…ูˆุฌูˆุฏ ู„ู„ security ุงูˆ ุงู†ูŠ check ู‡ู„ ุงู„ุฏุงุชุง ุฏูŠ ุตุญ ุงูˆ ุญุตู„ ููŠู‡ุง ู…ุดูƒู„ู‡ ูˆู‡ูŠ ุฌุงูŠู‡ ู…ู† ุงู„ master ูˆู„ุง ู„ุง ูŠุนู†ูŠ ู‡ูˆ ู…ููŠู‡ุด check sum ูˆู„ุง ููŠู‡ CRC ูˆู„ุง ููŠู‡ parity ุญุชูŠ ูู…ุด ู‡ุนุฑู ูƒุฏุง ุงุชุฃูƒุฏ ู…ู† ู…ุตุฏุงู‚ูŠุฉ ุงู„ุฏุงุชุง ุงู„ู„ูŠ ุฌุงุชู„ูŠ ุฏูŠ

2- ุงู„ุณุจุจ ุงู„ุชุงู†ูŠ ุงู† ู…ุณุงูุฉ ุชูˆุตูŠู„ master/slave ุจุงู„ SPI ุจุชูƒูˆู† ููŠ ุญุฏูˆุฏ 10 cm ุทุจ ู‚ูˆู„ูŠ ุงู†ุช ุจู‚ูŠ ุงุฐุงูŠ ู‡ุชูˆุตู„ ุจูˆุฑุฏุชูŠู† ููŠ ุงู„ุนุฑุจูŠู‡ ุฏูŠ ููŠ zone ูˆุฏูŠ zone ุชุงู†ูŠู‡ ูˆุงู„ู…ุณุงูุฉ ุจูŠู†ู‡ู… ู…ู…ูƒู† ุชูˆุตู„ ู„ ุงุชู†ูŠู† ูˆู„ุง ุชู„ุงุชู‡ ู…ุชุฑ! ู…ุด ู‡ูŠู†ูุน ุทุจุนุง.

3- ุงู„ SPI ู‡ูˆ Single master multiple slave ูˆู‚ูˆู„ู†ุง ุงู† ุงู„ slave ู…ูŠู‚ุฏุฑ ูŠุจุนุช ู…ู† ู†ูุณู‡ ูˆู„ุงุฒู… ุงู„ master ู‡ูˆ ุงู„ู„ูŠ ูŠุฌูŠ ูŠู‚ูˆู„ู‡ ู„ูˆ ุนู†ุฏูƒ ุฏุงุชุง ุงุจุนุชู‡ุง ู„ุงู† ุงู„ master ู‡ูˆ ุงู„ู„ูŠ ุจูŠ generate ุงู„ clock.

/**************/

--ุงุฎุฑ ุญุชู‡ ู…ุด ุงุญู†ุง ู‚ูˆู„ู†ุง ูŠุง ุญุณู†
ุงู„ master ู‡ูˆ ุงู„ู„ูŠ ุจูŠุฏูŠุฑ ุงูŠ ุนู…ู„ูŠุฉ ุชูˆุงุตู„ ูŠุนู†ูŠ ู‡ูˆ ุงู„ู„ูŠ ุจูŠุฑูˆุญ ูŠูƒู„ู… ุงู„ slave ุนุดุงู† ูŠุจุนุช ู„ูŠู‡ ุฏุงุชุง ุนู†ุฏู‡ ุงูˆ ูŠุฑูˆุญ ู„ู„ slave ูŠู‚ูˆู„ู‡ ุนู†ุฏูƒ ุฏุงุชุง ุŸ ู„ูˆ ุนู†ุฏูƒ ุงุจุนุช
ู…ุชุฎูŠู„ ุงู† ุงู„ slave ู„ูˆ ุนู†ุฏู‡ data ุนุงูŠุฒ ูŠุจุนุชู‡ุง ู„ู„ master ู…ูŠู‚ุฏุฑ ูŠุนู…ู„ ุงูŠ ุญุงุฌู‡ ุนุดุงู† ูŠุนุฑู ุงู„ Master ุงู†ู‡ ุนู†ุฏู‡ data ูˆูƒู…ุงู† ู…ูŠู‚ุฏุฑ ูŠุจุนุชู‡ุง ู„ุงู† ู‡ูˆ slave ูˆุงุญู†ุง ู‚ูˆู„ู†ุง ุงู„ู„ูŠ ุจูŠุนู…ู„ generate ู„ู„ clock ู‡ูˆ ุงู„ master ูˆู‚ูˆู„ู†ุง ุงู† ุนุดุงู† ุงุจุชุฏูŠ ุงุจุนุช ุฏุงุชุง ู„ุงุฒู… ุงุนู…ู„ ุญุงุฌุชูŠู† ุงุดุบู„ ุงู„ clock ูˆุงู†ุฒู„ ุงู„ pin ุจุชุงุนุช ุงู„ ss ู…ู† high ู„ low ุตุญ ุŸ

--ุทูŠุจ ู„ูˆ ุงู„ slave ุจู‚ู‰ ุนู†ุฏู‡ ุฏุงุชุง ูˆุนุงูŠุฒูŠู† ู†ุฎู„ูŠู‡ ูŠุนุฑู ูŠุจุนุชู‡ุง ุฏู„ูˆู‚ุช ู…ุด ูŠุณุชู†ูŠ ุงู„ master ูŠุฌูŠ ูŠุณุงู„ ุŸ
--ู‡ู†ุง ุงุญู†ุง ู‡ู†ุญุงูˆู„ ู†ุฌุชู‡ุฏ ูˆู†ุดุบู„ ุฏู…ุงุบู†ุง ูŠุง ุญุณู† ุนุดุงู† ู†ุนุฑู ู†ุนู…ู„ ุงุฏู‡ ู‡ูŠ ู…ุด ู…ูˆุฌูˆุฏู‡ ููŠ ุงู„ Spi ูƒ peripheral ุงู‡ ูˆู„ูƒู† ู‡ู†ุญุงูˆู„ ู†ุณุชุนูŠู† ุจุญุงุฌู‡ ุชุงู†ูŠู‡
--ู‡ูˆ ูƒู„ ุงู„ููƒุฑู‡ ุงู† ู„ู…ุง ุงู„ slave ูƒุงู† ู…ุนุงู‡ ุฏุงุชุง ูˆุนุงูŠุฒ ูŠุจุนุชู‡ุง ู„ู„ master ู…ูƒู†ุด ููŠู‡ ุชูˆุงุตู„ ุจูŠู† ุงู„ุงุชู†ูŠู† micro ู…ู† ุฎู„ุงู„ ุงู„ spi ููŠ ุงู„ูˆู‚ุช ุงู„ุญุงู„ูŠ ูุงู„ู…ุดูƒู„ู‡ ุจุณ ุงู† ุงู„ slave ุนุงูŠุฒ ูŠุนุฑู ุงู„ master ุงู†ุง ุนู†ุฏูŠ ุฏุงุชุง ุชุนุงู„ูŠ ุงุนู…ู„ูŠ generation ู„ู„ clock ูˆู†ุฒู„ูŠ ุงู„ Slave select ุจุชุงุนุชูŠ ู…ู† high ู„ low ุนุดุงู† ุงู‚ุฏุฑ ุงุจุนุชู„ูƒ

--ู‡ูˆ ู…ู…ูƒู† ู…ุซู„ุง ูŠุง ุญุณู† ุงู„ slave ู…ุซู„ุง ูŠ Configure pin ุชูƒูˆู† output ูˆู…ุชูˆุตู„ู‡ ุจุงู„ master ุนู„ูŠ external interrupt pin ูˆู„ู…ุง ุงู„ Slave ูŠูƒูˆู† ุนู†ุฏู‡ ุฏุงุชุง ุนุงูŠุฒ ูŠุจุนุชู‡ุง ูˆู‚ุชูŠ ูˆุจุฏูˆู† ู…ูŠู†ุชุธุฑ ุงู„ master ุงู†ู‡ ูŠุฌูŠ ุฑุงูุน ุงู„ pin ุฏูŠ ู„ high ูˆู†ูƒูˆู† ุนู†ุฏ ุงู„ mater ู…ู‡ู†ุฏู„ูŠู† ููŠ ุงู„ ISR ุจุชุงุน ุงู„ EXTI ุฏู‡ ุงู† ู„ูˆ ุญุตู„ rising edge ุนู„ูŠ ุงู„ external interrupt pin ุฏูŠ ุงู† ุงู„ master ูŠุจุชุฏูŠ ูŠ generate clock ูˆูŠู†ุฒู„ ุงู„ Slave select ุจุชุงุนุช ุงู„ Slave ุฏู‡ ูˆุจูƒุฏุง ู‚ุฏุฑู†ุง ู†ุฎู„ูŠ ุงู„ slave ู„ูˆ ุนู†ุฏู‡ ุฏุงุชุง ู…ู‡ู…ู‡ ูˆุนุงูŠุฒ ูŠุจูŠุนู‡ุง ูˆู‚ุชูŠ ูˆุจุฏูˆู† ู…ูŠู†ุชุธุฑ ุงู„ master ุงู†ู‡ ูŠุฌูŠ ูŠุณุฃู„ู‡ ู„ุง ุงุชุญู„ุช ุงู‡ูˆ.

/********************/

---ุจูƒุฏุง ุงู„ุญู…ุฏู„ู„ู‡ ู†ูƒูˆู† ุฌุงูˆุจู†ุง ุนู„ูŠ ุงู„ุณุคุงู„ ุจุชุงุนู†ุง ูˆู…ุนู„ุด ู„ูˆ ุจุฏุฎู„ ููŠ ุชูุงุตูŠู„ ูˆู„ูƒู† ุจุจู‚ูŠ ุนุงูŠุฒ ุงุนุฑููƒ ุงู„ุตูˆุฑุฉ ูƒุงู…ู„ุฉ ุนุดุงู† ุงู„ู…ูˆุถูˆุน ูŠุซุจุช ูˆุชูู‡ู…ู‡ ุจุดูƒู„ ุนู…ูŠู‚.
---ูƒู…ุงู† ู‡ุชู„ุงู‚ูŠ ูƒู„ ุงู„ุจูˆุณุชุณ ุงู„ู„ูŠ ู‚ุจู„ ูƒุฏุง ุนู„ูŠ ุงู„ู‡ุดุชุงุฌ ุฏู‡ ูˆุฏู‡ ุณูˆุงุก ู‡ู†ุง ุงูˆ ุนู„ูŠ ู„ูŠู†ูƒุฏุงู†.
---ูˆุทุจุนุง ู„ูˆ ูˆุตู„ุช ู„ู‡ู†ุง ู…ุชู†ุณุงุด ุชุฏุนูŠู„ูŠ + ุงู†ุง ู‡ุจู‚ู‰ ุณุนูŠุฏ ุฌุฏุง ู„ูˆ ุงู†ุช ูˆุตู„ุช ู„ู‡ู†ุง

/********************

Want your school to be the top-listed School/college in Cairo?

Click here to claim your Sponsored Listing.

Location

Category

Address

Cairo