很高兴为你解答,STC12C5A60S2也可以用89C52的,不过就是少了很多寄存器的地址说明,建议你将reg52.h这个头文件复制出来,在加上stc12c5a60s2的一些特殊寄存器的地址声明,然后改名为stc12c5a60s2.h(自己取名字)就可以了 ,希望我的回答对你有帮助!
把STC12C5A60S2单片机的头文件加入进<reg52>,直接复制进去不可以。把STC12C5A60S2.H写进去就可以了。单片机(Microcontrollers)是一种集成电路芯片,是采用超大规模集成电路技术把具有数据处理能力的中央处理器CPU、随机存储器RAM、只读存储器ROM、多种I/O口和中断系统、定时器/计数器等功能(可能还包括显示驱动电路、脉宽调制电路、模拟多路转换器、A/D转换器等电路)集成到一块硅片上构成的一个小而完善的微型计算机系统,在工业控制领域广泛应用。从上世纪80年代,由当时的4位、8位单片机,发展到现在的300M的高速单片机。
P4.4,P4.5,P4.6口是特别的,默认是第二功能,当IO口用需对P4SW寄存器设置(注意下面代码第67行),可参考下载器中的官方IO *** 作例程,更详细的参考相应手册.
很多基本程序模板STC的新版下载器里都帮你打包好了,可以参考的
/*------------------------------------------------------------------*//* --- STC MCU Limited ---------------------------------------------*/
/* --- STC12C5Axx Series MCU IO Demo -------------------------------*/
/* --- Mobile: (86)13922805190 -------------------------------------*/
/* --- Fax: 86-0513-55012956,55012947,55012969 ---------------------*/
/* --- Tel: 86-0513-55012928,55012929,55012966----------------------*/
/* --- Web:
*/
/* --- Web:
*/
/* If you want to use the program or the program referenced in the */
/* article, please specify in which data and procedures from STC */
/*------------------------------------------------------------------*/
#include "reg51.h"
sbit P00 = P0^0
sbit P01 = P0^1
sbit P02 = P0^2
sbit P03 = P0^3
sbit P04 = P0^4
sbit P05 = P0^5
sbit P06 = P0^6
sbit P07 = P0^7
sbit P10 = P1^0
sbit P11 = P1^1
sbit P12 = P1^2
sbit P13 = P1^3
sbit P14 = P1^4
sbit P15 = P1^5
sbit P16 = P1^6
sbit P17 = P1^7
sbit P20 = P2^0
sbit P21 = P2^1
sbit P22 = P2^2
sbit P23 = P2^3
sbit P24 = P2^4
sbit P25 = P2^5
sbit P26 = P2^6
sbit P27 = P2^7
sbit P30 = P3^0
sbit P31 = P3^1
sbit P32 = P3^2
sbit P33 = P3^3
sbit P34 = P3^4
sbit P35 = P3^5
sbit P36 = P3^6
sbit P37 = P3^7
sfr P4 = 0xC0
sbit P40 = P4^0
sbit P41 = P4^1
sbit P42 = P4^2
sbit P43 = P4^3
sfr P4SW = 0xBB // - LVD_P4.6 ALE_P4.5 NA_P4.4 - - - -
void delay()
{
int i, j
for (i=0 i<1000 i++)
for (j=0 j<500 j++)
}
void main()
{
P4SW = 0x70
P10 = 0
delay()
P10 = 1
P11 = 0
delay()
P11 = 1
P12 = 0
delay()
P12 = 1
P13 = 0
delay()
P13 = 1
P14 = 0
delay()
P14 = 1
P15 = 0
delay()
P15 = 1
P16 = 0
delay()
P16 = 1
P17 = 0
delay()
P17 = 1
P30 = 0
delay()
P30 = 1
P31 = 0
delay()
P31 = 1
P32 = 0
delay()
P32 = 1
P33 = 0
delay()
P33 = 1
P34 = 0
delay()
P34 = 1
P35 = 0
delay()
P35 = 1
P36 = 0
delay()
P36 = 1
P37 = 0
delay()
P37 = 1
P20 = 0
delay()
P20 = 1
P21 = 0
delay()
P21 = 1
P22 = 0
delay()
P22 = 1
P23 = 0
delay()
P23 = 1
P24 = 0
delay()
P24 = 1
P25 = 0
delay()
P25 = 1
P26 = 0
delay()
P26 = 1
P27 = 0
delay()
P27 = 1
P00 = 0
delay()
P00 = 1
P01 = 0
delay()
P01 = 1
P02 = 0
delay()
P02 = 1
P03 = 0
delay()
P03 = 1
P04 = 0
delay()
P04 = 1
P05 = 0
delay()
P05 = 1
P06 = 0
delay()
P06 = 1
P07 = 0
delay()
P07 = 1
P40 = 0
delay()
P40 = 1
P41 = 0
delay()
P41 = 1
P42 = 0
delay()
P42 = 1
P43 = 0
delay()
P43 = 1
while (1)
{
P1 = 0x00
delay()
P1 = 0xff
P3 = 0x00
delay()
P3 = 0xff
P2 = 0x00
delay()
P2 = 0xff
P0 = 0x00
delay()
P0 = 0xff
P4 = 0x00
delay()
P4 = 0xff
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)