51單片機快速入門教程
潘志銘、李健輝、張博、董磊
買這商品的人也買了...
-
$210$200
相關主題
商品描述
《51單片機快速入門教程》以實例為主導,以51 核心板為開發平臺,涵蓋了51 單片機開發基礎、C51 程序設計基礎、I/O 引腳、中斷、定時器/計數器、通信、看門狗、Flash 等內容,詳細介紹了STC89 C52RC芯片的大部分片上功能。本書10 個實例均包括每章實例所需要的知識、實例與代碼解析、思考題和應用實踐四大環節,每個實例都有詳細的步驟和源代碼。本書章節名稱中帶有“*”標志的為選讀內容,但並不意味著這部分內容不重要。讀者可以根據自己的學習需求選擇是否閱讀。 《51單片機快速入門教程》配套的資料包既包括51 核心板原理圖、例程、軟件包、軟件資料,又包括配套的PPT講義、視頻等資料,且持續更新。**下載鏈接可通過微信公眾號“卓越工程師培養系列”獲取。編者建議,在學習本書的過程中,讀者不僅要看要練,更要勤學多思。讀者在閱讀章節內容後,可在獨立思考的情況下編寫實例代碼,最後獨立完成思考題和應用實踐部分。 《51單片機快速入門教程》既可作為高等院校相關專業的教材,也可供從事單片機開發的工程技術人員參考。
目錄大綱
第1 章 STC89 C52RC 開發平臺和
工具·············································· 1
1.1 初識單片機··························2
1.1.1 單片機的概念·······················2
1.1.2 常見的51 單片機種類·············2
1.1.3 STC 單片機的命名規則···········3
1.2 STC89 C52RC 介紹················4
1.2.1 結構框架·····························4
1.2.2 引腳功能·····························5
1.2.3 *存儲結構····························7
1.3 *51 核心板最小系統電路
介紹································· 10
1.3.1 電源電路··························· 10
1.3.2 時鐘電路··························· 11
1.3.3 復位電路··························· 12
1.4 搭建開發環境····················· 13
1.4.1 本書資料包························ 13
1.4.2 Keil C51 的安裝及設置·········· 13
1.4.3 STC-ISP 程序下載環境配置··· 18
思考題····································· 21
應用實踐·································· 21
第2 章 C51 程序設計基礎···················22
2.1 C51 程序的基本組成部分······ 23
2.1.1 包含頭文件························ 23
2.1.2 主函數······························ 23
2.1.3 標識符與關鍵字·················· 24
2.1.4 程序註釋··························· 24
2.1.5 其他規範····························24
2.2 C51 數據類型····················· 25
2.2.1 基本數據類型······················25
2.2.2 擴展數據類型······················26
2.3 C51 變量與常量·················· 26
2.3.1 變量··································27
2.3.2 常量··································29
2.4 C51 運算符························ 29
2.4.1 算術運算符·························29
2.4.2 關系運算符·························30
2.4.3 邏輯運算符·························30
2.4.4 位運算符····························31
2.5 C51 程序結構····················· 31
2.5.1 順序結構····························32
2.5.2 選擇結構····························32
2.5.3 循環結構····························35
2.6 C51 函數··························· 38
2.6.1 函數的定義·························38
2.6.2 函數的聲明·························39
2.6.3 函數的參數·························39
2.6.4 函數的返回值······················39
2.6.5 函數的調用·························39
2.6.6 內部函數····························40
2.6.7 函數的命名規範···················41
2.7 C51 數組··························· 41
2.7.1 數組的定義·························41
2.7.2 數組的初始化······················41
2.7.3 數組元素的引用···················41
2.7.4 *二維數組·························· 42
2.7.5 字符串數組························ 42
2.7.6 數組的命名規範·················· 43
2.8 *C51 指針·························· 43
2.8.1 指針變量的定義和使用········· 44
2.8.2 指針變量的註意事項············ 45
2.8.3 指針與數組························ 45
2.9 Keil 編輯和編譯及程序下載··· 46
2.9.1 新建Keil 工程····················· 46
2.9.2 新建並添加main.c 文件········· 48
2.9.3 配置工程··························· 49
2.9.4 編寫程序代碼····················· 49
2.9.5 程序編譯··························· 50
2.9.6 STC-ISP 程序下載················ 51
思考題····································· 53
應用實踐·································· 53
第3 章 LED 流水燈······························ 54
3.1 LED 燈的工作原理·············· 55
3.2 I/O 引腳部分寄存器············· 55
3.3 I/O 引腳控制的方法············· 56
3.3.1 字節操作··························· 56
3.3.2 位操作······························ 57
3.4 *I/O 引腳的內部結構············ 57
3.4.1 P0 組I/O 引腳····················· 57
3.4.2 P1 組I/O 引腳····················· 59
3.4.3 P2 組I/O 引腳····················· 60
3.4.4 P3 組I/O 引腳····················· 61
3.5 實例與代碼解析·················· 62
3.5.1 位操作控制流水燈··············· 63
3.5.2 字節操作控制流水燈············ 66
思考題····································· 67
應用實踐·································· 68
第4 章 獨立按鍵輸入·························· 69
4.1 按鍵檢測原理····················· 70
4.2 按鍵軟件去抖原理··············· 70
4.3 實例與代碼解析·················· 72
思考題····································· 75
應用實踐·································· 75
第5 章 蜂鳴器······································ 76
5.1 蜂鳴器介紹························ 77
5.2 蜂鳴器的工作原理··············· 77
5.3 實例與代碼解析·················· 78
思考題····································· 80
應用實踐·································· 80
第6 章 數碼管顯示······························ 82
6.1 數碼管介紹························ 83
6.2 數碼管的工作原理··············· 85
6.3 數碼管靜態顯示·················· 86
6.4 數碼管動態顯示·················· 86
6.5 實例與代碼解析·················· 87
思考題····································· 90
應用實踐·································· 91
第7 章 外部中斷·································· 92
7.1 中斷的概念························ 93
7.2 中斷系統框架····················· 94
7.2.1 中斷源·······························94
7.2.2 中斷觸發條件······················95
7.2.3 中斷請求標志······················97
7.2.4 中斷允許控制······················98
7.2.5 中斷優先級·························99
7.2.6 中斷處理··························101
7.3 實例與代碼解析·················103
思考題····································105
應用實踐·································105
第8 章 定時器/計數器·······················107
8.1 機器周期與時鐘周期···········108
8.2 定時器/計數器的工作原理····108
8.3 定時器/計數器系統框架·······110
8.3.1 定時/計數功能的選擇········· 110
8.3.2 定時器/計數器的運行控制··· 111
8.3.3 工作模式與計數初值·········· 112
8.3.4 定時器/計數器中斷············ 114
8.4 實例與代碼解析·················117
8.4.1 計數器控制LED 燈············ 117
8.4.2 定時器控制LED 燈············ 120
思考題····································123
應用實踐·································123
第9 章 PWM 與呼吸燈·····················124
9.1 PWM 基本參數··················125
9.1.1 電平標準························· 125
9.1.2 周期和頻率······················ 125
9.1.3 占空比···························· 125
9.2 PWM 控制LED 亮度的
原理································126
9.3 PWM 輸出原理··················126
9.3.1 輸出PWM 信號················ 126
9.3.2 按照規律調節PWM 占空比···· 127
9.4 實例與代碼解析·················129
思考題····································133
應用實踐·································133
第10 章 串口通信······························134
10.1 通信協議介紹··················135
10.1.1 並行通信和串行通信······ 135
10.1.2 單工、半雙工和全雙工
數據傳輸····················· 136
10.2 串口通信協議介紹············136
10.2.1 UART 物理層··············· 137
10.2.2 UART 數據幀格式········· 137
10.2.3 UART 傳輸速率············ 138
10.2.4 UART 通信實例············ 138
10.3 UART 電路原理圖·············139
10.4 串口中斷························140
10.4.1 串口中斷請求標志位·······140
10.4.2 串口中斷允許控制位·······141
10.4.3 *串口中斷優先級
控制位·························141
10.5 串口工作模式··················142
10.5.1 *工作模式0 ··················143
10.5.2 工作模式1····················143
10.5.3 *工作模式2 ··················147
10.5.4 *工作模式3 ··················149
10.6 實例與代碼解析···············149
思考題····································155
應用實踐·································155
第11 章 看門狗··································157
11.1 復位方法························158
11.1.1 外部RST 引腳復位·········158
11.1.2 軟件復位······················158
11.1.3 通電/關電復位···············159
11.1.4 看門狗復位···················159
11.2 看門狗相關寄存器············159
11.3 看門狗溢出時間···············160
11.4 看門狗喂狗操作···············161
11.5 實例與代碼解析···············161
思考題····································164
應用實踐·································165
第12 章 內部Flash 讀寫··················166
12.1 ISP 與IAP·······················167
12.2 內部Flash 存儲結構··········167
12.3 IAP 讀寫與擦除Flash 的
方法······························168
12.3.1 讀取操作······················169
12.3.2 擦除操作······················170
12.3.3 寫入操作······················171
12.4 Flash 讀寫註意事項···········172
12.5 實例與代碼解析···············173
思考題····································181
應用實踐·································181
附錄·························································182
附錄A 數制及轉換方法············183
附錄B 邏輯門表示符號············185
附錄C 常用寄存器及部分位的
解釋說明·····················186
附錄D 51 核心板電路圖···········191
參考文獻·················································192