⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 冷火MCF52255开发板精华资料
💻 C
字号:
/*广州穗佳电子科技有限公司
  冷火MCF52255多功能开发板
  更多精彩产品,关注穗佳电子淘宝店
  http://sogadz.taobao.com*/
#include "support_common.h" /* include peripheral declarations and more */
#if (CONSOLE_IO_SUPPORT || ENABLE_UART_SUPPORT) 
/* Standard IO is only possible if Console or UART support is enabled. */
#include <stdio.h>
#endif


#define uchar unsigned char 
#define uint unsigned int 




/*********************************************/  //延时     /*********************************************/
void delay(int xms)        //xms毫秒延时
{
    int ii,jj;
    
    for(ii=0;ii<xms;ii++)
    for(jj=0;jj<2000;jj++); 
       
}
void delay_us(int xus)     //xus微秒延时
{
    int ii,jj;
    
    for(ii=0;ii<xus;ii++)
    for(jj=0;jj<2;jj++);    
}

/*********************************************/  //流水灯,数码管 蜂鸣器 /*********************************************/



#define Du MCF_GPIO_PORTUC_PORTUC0 	//段选锁存器控制端
#define We MCF_GPIO_PORTUC_PORTUC1 	//位选锁存器控制端

#define Du_1 MCF_GPIO_PORTUC|=Du 	//段选锁存器控制端置1
#define We_1 MCF_GPIO_PORTUC|=We 	//位选锁存器控制端置1

#define Du_0 MCF_GPIO_PORTUC&=~Du 	//段选锁存器控制端置0
#define We_0 MCF_GPIO_PORTUC&=~We 	//位选锁存器控制端置0


#define Beeper MCF_GPIO_PORTUC_PORTUC3
#define Beeper_1 MCF_GPIO_PORTUC|=Beeper
#define Beeper_0 MCF_GPIO_PORTUC&=~Beeper



#define LED_EN MCF_GPIO_PORTTJ_PORTTJ7	//LED 使能EN信号
#define LED_EN_0 MCF_GPIO_PORTTJ=0x0f
#define LED_EN_1 MCF_GPIO_PORTTJ=0x8f

void IO_init() 
{
   
    MCF_GPIO_PTJPAR = 0x00;      // 配置PTJ为普通IO    
    MCF_GPIO_DDRTJ = 0xff;    // 设置PTJ为输出
    MCF_GPIO_PORTTJ = 0x00;   //关闭PTJ口
    
    MCF_GPIO_PUCPAR = 0x00;      // 配置PUC为普通IO    
    MCF_GPIO_DDRUC = 0xff;    	// 设置PUC为输出
    MCF_GPIO_PORTUC = 0x08;      //关闭PUC口
    
}

void led(uchar n) //n;显示内容
{


	MCF_GPIO_PORTTJ=0;		//流水灯控制端
	Du_1;		//段选锁存器
	Du_0;
	
	LED_EN_0;	//流水灯公共端
	We_1;		//位选锁存器
	We_0;
	
	MCF_GPIO_PORTTJ=n;		//流水灯控制端
	Du_1;		//段选锁存器
	Du_0;

}


/**********************************************************************************************************
**********************************************************************************************************/

void main(void) 
{
	
	int counter;
	int i=0,j=0,k=0;

    IO_init();
   
    

	//******************流水灯******************
	j=0x80;		
    while(1) 
    {
   
    	led(j);
    	delay(1000);
    	j>>=1;
    	if(j==0)j=0x80;
    	
    }
   



    
} 


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -