60 likes | 215 Views
介面設計專題實務 Object Teaching of Interface Design 實驗三 開關實驗. 授課教師:任才俊. 實驗目的. (a) 瞭解資料匯流排與位址匯流排的意義。 (b) 瞭解數位輸入與輸出的用法。. 實驗說明. 8 位元的數位量輸入 ( 由八指撥開關產生 ) 當指撥開關切到靠近 LED 時為低,相反為高,通過 74LS244 緩衝連接到 DSP 的資料匯流排的低 8 位元。 8 位元的數字量輸出 ( 通過八個 LED 燈顯示 ) 當對應 LED 點亮時說明輸出為低,熄滅時為高,通過 74LS273 緩衝連接到 DSP 的資料匯流排的低 8 位元。
E N D
介面設計專題實務Object Teaching of Interface Design實驗三 開關實驗 授課教師:任才俊
實驗目的 • (a)瞭解資料匯流排與位址匯流排的意義。 • (b)瞭解數位輸入與輸出的用法。
實驗說明 • 8位元的數位量輸入(由八指撥開關產生)當指撥開關切到靠近LED時為低,相反為高,通過74LS244緩衝連接到DSP的資料匯流排的低8位元。8位元的數字量輸出(通過八個LED燈顯示)當對應LED點亮時說明輸出為低,熄滅時為高,通過74LS273緩衝連接到DSP的資料匯流排的低8位元。 • 實驗中採用簡單的一一映射關係來對資料位址進行驗證,目的是使實驗者能夠對資料一目了然的認識,在本實驗中,提供的資料空間配置如下: • CS2基底位址:0x8000 • CPU的資料空間:基底位址+0x8000 • 指撥開關input 8位元:通過74LS244擴充 • CPU的資料空間:基底位址+0x8001 • LED燈output 8位元:通過74LS273擴充
//------------------頭文件-------------------------------------////------------------頭文件-------------------------------------// #include "DSP281x_Device.h" // DSP281x Headerfile Include File #include "DSP281x_Examples.h" // DSP281x Examples Include File //------------------主程序-------------------------------------// void main(void) { unsigned int temp; temp = 0; // Initialize System Control: // PLL, WatchDog, enable Peripheral Clocks InitSysCtrl(); // Disable CPU interrupts DINT; // Initialize PIE control registers to their default state. // The default state is all PIE interrupts disabled and flags // are cleared. InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). InitPieVectTable();
for(;;) { asm(" nop "); //讀入0x88000地址的開關量值並賦給temp temp = *(int *)0x88000&0x00ff; asm(" nop "); //temp值輸出0x88001地址的LED燈 *(int *)0x88001 = temp; asm(" nop "); } }
練習題 • 設計三種不同跑馬燈,設定開關1時跑第1種,第二個開關跑第二種,第三個開關跑第三種。都沒設定開關,或者模式以外的狀況,則LED全滅。