本帖最后由 strang 于 2011-8-19 00:31 编辑
/*---------------------------------------------------------------------------------------------------------*/
/* */
/* Copyright(c) 2009 Nuvoton Technology Corp. All rights reserved. */
/* */
/*---------------------------------------------------------------------------------------------------------*/
#include <stdio.h>
#include "NUC1xx.h"
#include "Driver\DrvGPIO.h"
#include "Driver\DrvSYS.h"
unsigned char Table[18]=
{
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00,0xff
};
/*
*********************************************************************************************************
** 函数名称 :
** 函数功能 :
** 调试说明 :
*********************************************************************************************************
*/
unsigned char disp(unsigned int data,unsigned char weixuan)
{
GPIOA->DOUT|=(0xff<<0);
GPIOA->DOUT&= ~(Table[data]<<0);
switch(weixuan)
{
case 1:
GPIOA->DOUT&=~(1<<9);
GPIOA->DOUT|=(1<<8);
break;
case 2:
GPIOA->DOUT&=~(1<<8);
GPIOA->DOUT|=(1<<9);
break;
default:break;
}
}
unsigned char dispsiwei(unsigned char qian,unsigned char bai)
{
unsigned int i;
for(i=0;i<=7500;i++)
{
}
disp(qian,1);
for(i=0;i<=7500;i++)
{
}
disp(bai,2);
for(i=0;i<=7500;i++)
{
}
}
/*************************************************************************************
** Function name:
** Descriptions:
**
** input parameters:
** output parameters:
** Returned value:
*************************************************************************************/
int main (void)
{
unsigned int i;
unsigned int j;
/* SYSCLK =>12Mhz*/ //外部晶振使能
UNLOCKREG();
SYSCLK->PWRCON.XTL12M_EN = 1;
LOCKREG();
GPIOA->PMD.PMD0=1;
GPIOA->PMD.PMD1=1;
GPIOA->PMD.PMD2=1;
GPIOA->PMD.PMD3=1;
GPIOA->PMD.PMD4=1;
GPIOA->PMD.PMD5=1;
GPIOA->PMD.PMD6=1;
GPIOA->PMD.PMD7=1;
GPIOA->PMD.PMD8=1;
GPIOA->PMD.PMD9=1;
while (1)
{
for(j=0;j<=17;j++)
{
for(i=0;i<=100;i++)
{
dispsiwei(j,j);
}
}
}
return 0;
}
/*
作者:21IC_strang
2011-08-15
实现功能:0~9,A~F 循环,数码管显示
接线方式: 主板 显示板
PA.0----La
PA.1----Lb
PA.2----Lc
PA.3----Ld
PA.4----Le
PA.5----Lf
PA.6----Lg
PA.7----Ldp
PA.8----S1
PA.9----S2
VDD ----VCC
*/
Protel Schematic.pdf
(59.63 KB)
显示板原理图
显示板照片
cortex-m0两位数码管.rar
(536.75 KB)
数码管显示程序
收到板子,了解硬件结构,看了好几天数据手册,寄存器和库文件,终于能下手了,本人白天上班,只有晚上才有时间学习,所以进度比较慢。由于助学板只能通过串口助手看数据,为了方便,就外接了两位数码管(显示板是原来做项目用的),本人初学,如有错误和不当之处,请多多指教,谢谢! |