Presentation is loading. Please wait.

Presentation is loading. Please wait.

LED Pili LED 中州技術學院 電子系 副教授 余文俊.

Similar presentations


Presentation on theme: "LED Pili LED 中州技術學院 電子系 副教授 余文俊."— Presentation transcript:

1 LED Pili LED 中州技術學院 電子系 副教授 余文俊

2 LED顯示電路

3 2-1 LED顯示電路 輸出’1’或’H’LED亮 輸出’0’或’L’LED滅
74245為緩衝器

4 PSOC 一般I/O代號 PRT0DR8 bits8051之 P0 PRT1DR8 bits8051之P1
Example 1:output PRT0DR=0xf0; // P0= PRT0DR=0x0f; // P0= PRT0DR=0xaa; // P0= Example 2 :output unsigned char i=0; for (i=0;i<=256;i=i+8) { PRT1DR=i; }

5 請將 JP1,P3與 JP5用 8-PIN雙排 JUMP連接短路起來,而 SW8,SW9,與 SW10則往下切換以將其他控制 PORT開關 OFF
進入 PSoC Designer後,請點選 Device Edit 的 Interconnect View,將 GlobalResources 的 CPU_Clock選在 KHz(最低速處理),再將所有腳位的 Drive狀態選擇為 Strong類型切記 Strong只能當輸出 設定CPU工作頻率 設定IC 接腳為output

6 #include <m8c.h> #include "PSoCAPI.h" void delay(unsigned int x); void main() { while(1) delay(500); PRT0DR=0x55; PRT1DR=0x55; PRT2DR=0x55; PRT0DR=0xaa; PRT1DR=0xaa; PRT2DR=0xaa; } void delay(unsigned int x) unsigned i; for ( i = 0;i < x;i++ ) ; 當硬體設定完畢後,請點選工具列 Application Editor去編輯 Source Files 內的 main.c,然後鍵入基本 LED閃爍程式。

7 PILI LED void delay(unsigned int x) { unsigned int i;
#include <m8c.h> #include "PSoCAPI.h" void delay(unsigned int x); void main(void) { while(1) unsigned char j,i=0x01; for(j=0;j<8;j++) PRT0DR=i; delay(200); i=i<<1; } //enf of for } // end of while } // end of main void delay(unsigned int x) { unsigned int i; for ( i = 0;i < x;i++ ) ; }

8 練習題 8 個LED右移作(pili) 8 個LED左移作(pili) 8 個LED左右移作(pili) 16個LED右移作(pili)

9 若是用組合語言來編輯程式,則請撰寫 Source Files 內的 main.asm,並鍵入基本 LED閃爍程式


Download ppt "LED Pili LED 中州技術學院 電子系 副教授 余文俊."

Similar presentations


Ads by Google