資源描述:
《s08_05_freescale hcs08單片機鍵盤模塊編程應用【freescale 單片機原理及應用】》由會員上傳分享,免費在線閱讀,更多相關內容在教育資源-天天文庫。
1、Freescale單片機原理及應用FreescaleHCS08單片機鍵盤模塊編程應用Copyright?YangMing.2010.ElectronicsandInformationEngineeringDepartmentofHuazhongUniversityofScienceandTechnologyWuhan,Hubei430074,P.R.ChinaFreescaleHCS08單片機鍵盤模塊編程應用??ContentsandObjectives:ContentsandObjectives?理解矩陣鍵盤原理?掌握KBI模塊原理,學會KBI模塊設計?進一步認識
2、“對MCU外部管腳/內部模塊的控制正是通過Regs的控制來實現(xiàn)”Slide1Copyright?YangMing.2010.ElectronicsandInformationEngineeringDepartmentofHuazhongUniversityofScienceandTechnologyWuhan,Hubei430074,P.R.China5.1概述MC9S08AW60系列MCU內部具有一個鍵盤中斷KBI(KeyboardInterrupt)模塊,它具有8個鍵盤中斷輸入管腳,這8個管腳和端口D和端口G的管腳復用:?KBIP7、PTD7、AD15三者功能復
3、用。?當PTD7管腳允許作為KBIP7使用后,不管端口D的數(shù)據(jù)方向位為何值,管腳都被強制為輸入,端口D的上拉允許寄存器仍然用于控制上拉電阻,仍然可以通過讀端口D的數(shù)據(jù)寄存器來獲取端口狀態(tài)(不過這需要端口D的DDR的第7位為0)。?其余管腳和KBIP7類似Slide2Copyright?YangMing.2010.ElectronicsandInformationEngineeringDepartmentofHuazhongUniversityofScienceandTechnologyWuhan,Hubei430074,P.R.China5.1概述KBIP3~KBI
4、P0總是下降沿/低電平觸發(fā),KBIP7~KBIP4可以被配置成上升沿/高電平觸發(fā)或者下降沿/低電平觸發(fā)。當允許任何一個KBIP7~KBIP0管腳被允許并被配置為上升沿/高電平觸發(fā),且通過相應的端口上拉允許位為管腳允許了上拉電阻時,管腳的下拉電阻將取代上拉電阻。Slide3Copyright?YangMing.2010.ElectronicsandInformationEngineeringDepartmentofHuazhongUniversityofScienceandTechnologyWuhan,Hubei430074,P.R.China5.2內部結構及功能?
5、KBIP3~KBIP0結構相同?KBIP7~KBIP4結構相同Slide4Copyright?YangMing.2010.ElectronicsandInformationEngineeringDepartmentofHuazhongUniversityofScienceandTechnologyWuhan,Hubei430074,P.R.China5.2內部結構及功能?KBI1PE寄存器中的KBIPEn控制位允許用戶通過設定來選定相應的管腳作為KBI功能,當允許KBI功能(KBIPEn=1)時,同步邏輯監(jiān)測KBI1Pn管腳上的邊沿事件或邊沿和電平事件,一旦KBI1
6、Pn管腳出現(xiàn)脈沖事件,則KBI模塊會產生一個KBI中斷請求。Slide5Copyright?YangMing.2010.ElectronicsandInformationEngineeringDepartmentofHuazhongUniversityofScienceandTechnologyWuhan,Hubei430074,P.R.China5.2內部結構及功能?KBIP3~KBIP0總是下降沿/低電平觸發(fā)。?KBIP7~KBIP4可以被配置成上升沿/高電平觸發(fā)或者下降沿/低電平觸發(fā)?KBEDGn=0,監(jiān)測負邊沿事件?KBEDGn=1,監(jiān)測正邊沿事件Slide
7、6Copyright?YangMing.2010.ElectronicsandInformationEngineeringDepartmentofHuazhongUniversityofScienceandTechnologyWuhan,Hubei430074,P.R.China5.2內部結構及功能?到底是由邊沿觸發(fā)KBI中斷還是由電平觸發(fā)KBI中斷則由KBIMOD位確定:?KBIMOD=0,僅邊沿觸發(fā)KBI中斷?KBIMOD=1,邊沿和電平均可觸發(fā)KBI中斷Slide7Copyright?YangMing.2010.ElectronicsandInformat