其實就一條解決方案:研讀手冊!
- /*------------------------------------------------------------------*/
- /* --- STC MCU Limited ---------------------------------------------*/
- /* --- STC89-90xx Series MCU IO Demo -------------------------------*/
- /* --- Mobile: (86)13922805190 -------------------------------------*/
- /* --- Fax: 86-0513-55012956,55012947,55012969 ---------------------*/
- /* --- Tel: 86-0513-55012928,55012929,55012966----------------------*/
- /* --- Web: www.STCMCU.com -----------------------------------------*/
- /* --- Web: www.GXWMCU.com -----------------------------------------*/
- /* If you want to use the program or the program referenced in the */
- /* article, please specify in which data and procedures from STC */
- /*------------------------------------------------------------------*/
- //
- //由于P0口為開漏模式,所以需要外接10K左右的上拉電阻才可以正常測試
- //對于STC90C5xAD/STC9LEC5xAD系列,P4口的地址為 0C0H
- //
- //P4.5默認為ALE引腳,需要使用ISP下載軟件將它編程為P4.5口才可正常測試
- //
- #include "reg51.h"
- sfr P4 = 0xe8;
- sbit P46 = P4^6;
- sbit P45 = P4^5; //ISP下載需勾選"ALE腳用作P4.5口"
- sbit P44 = P4^4;
- sbit P43 = P4^3;
- sbit P42 = P4^2;
- sbit P41 = P4^1;
- sbit P40 = P4^0;
- //sfr P4 = 0xc0; //STC90C5xAD/STC9LEC5xAD系列
- void delay()
- {
- int i, j;
- for (i=0; i<1000; i++)
- for (j=0; j<500; j++);
- }
- void main()
- {
- P40 = 0;
- delay();
- P40 = 1;
- P41 = 0;
- delay();
- P41 = 1;
- P42 = 0;
- delay();
- P42 = 1;
- P43 = 0;
- delay();
- P43 = 1;
- P44 = 0;
- delay();
- P44 = 1;
- P45 = 0;
- delay();
- P45 = 1;
- P46 = 0;
- delay();
- P46 = 1;
- while (1)
- {
- P4 = 0x00;
- delay();
- P4 = 0xff;
- }
- }
復制代碼
|