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

📄 disp.c

📁 ARM开发板LPC2103,LED显示程序
💻 C
字号:
/****************************************Copyright (c)**************************************************
**                               Guangzou ZLG-MCU Development Co.,LTD.
**                                      graduate school
**                                 http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name:			main.c
** Last modified Date:  2004-09-16
** Last Version:		1.0
** Descriptions:		The main() function example template
**
**------------------------------------------------------------------------------------------------------
** Created by:			Chenmingji
** Created date:		2004-09-16
** Version:				1.0
** Descriptions:		The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "config.h"

uint8 MNBuff[16] = {        //静态显示码
0x7E,0x30,0x6D,0x79,		//0,1,2,3
0x33,0x5B,0x5F,0x70,		//4,5,6,7
0x7F,0x73,0x77,0x1F,		//8,9,A,B
0x4E,0x3D,0x4F,0x47			//C,D,E,F
};    //静态显示码

/************************************************************************************************
** Function name:   DelayNS
** Descriptions:    延时函数,S级
** input parameters:  
** output parameters:   无
** Returned value:      无
************************************************************************************************/
void DelayNS(uint8 tim)
{
     uint32 i;
     while(tim--)
         for(i = 0;i < 50000;i++);
}

/************************************************************************************************
** Function name:MN_Send_Byte
** Descriptions: 模拟I2C静态显示一个字节
** input parameters:  无
** output parameters: 无
** Returned value:    无
************************************************************************************************/
void MN_Send_Byte(uint8 d)   //模拟I2C发送一个显示码
{
    uint8 i = 8;
    while( i-- )
    {
        IO0CLR = 0x01;   //P0.0为SCK,P0.1为SDA
        IO0PIN = IO0PIN & (~0x02) | ((d & 0x01) << 1); 
        d = d >> 1; 
        IO0SET = 0x01; 
    }
}

/************************************************************************************************
** Function name:    Disp_Init
** Descriptions:     静态显示初始化,P0.0,P0.1分别作SCK和SDA
** input parameters:    无
** output parameters:   无
** Returned value:      无
************************************************************************************************/
void Disp_Init(void)
{
     PINSEL0 = PINSEL0 & (~0x0F);  //选择P0.0,P0.1分别作SCK和SDA
     IO0DIR = IO0DIR & (~0x03) | 0x03;   //选择为输出
     IO0SET = 1 | (1 << 1);
}

int main (void)
{// add user source code 
     uint8 i;
     Disp_Init();
     while(1)
     {
         for(i = 0;i < 10;i++)     //循环显示0-9
         {
             MN_Send_Byte(MNBuff[i]);
             DelayNS(150);
         }
     }
             
     return 0;
}
/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

⌨️ 快捷键说明

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