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

📄 二维数组1.c

📁 c51二维数组的应用及分析(编译除错,调试除错)
💻 C
字号:
#include<reg51.h>                              //整体   细处------
#include<stdio.h>								// 长时间内的短时间
unsigned  char  code  digit_code[10][5]=
{
	{0x3e,0x41,0x41,0x41,0x3e},                 //根椐任务时序要求,在时间上有读秒的,有闹钟
	{0x00,0x42,0x7f,0x40,0x00},                 //定时的.可以多种时间标志,主称序查标志做相应
	{0x42,0x61,0x51,0x49,0x46},                 //的处理
	{0x22,0x41,0x49,0x49,0x36},
	{0x18,0x14,0x12,0x7f,0x10},
	{0x27,0x45,0x45,0x45,0x39},                 //-----标志,变量(数据)处理在主函数,子函数,中
	{0x3c,0x4a,0x49,0x49,0x30},                //断中的分配
	{0x01,0x71,0x09,0x05,0x03},
	{0x36,0x49,0x49,0x49,0x36},
	{0x06,0x49,0x49,0x29,0x1e}
};                               //5X7字符  5列,7位
																  
unsigned char  number=0;           //初始为0.在本例中的中断中初始也
unsigned char  column=0;           // 为零 (全局变量)
void  delay(void);
void  init_time0(void);
void  isr_time0(void);


void  main(void)                    // ----- 一般先显数,再延时,再换数-----
{                                   //  ----------------------------------
	init_time0();                   //        这里是--先延时,标志或条件具备再变数 --- 
	while(1)                       //  
	{                    //-----400MS,既是组号的显示时间,也是换显数的间隔时间----------
		delay();                    //  组号和字符号分开,但都先时间再处理
		number=(number+1)%10;       //  除以10,取余数,亦0至9
	}                               //  ----哪一组  DELAY()字符显示时间
}                                   //  也是间隔时间
                                    //---------其思路先条件,再执行-----
void  delay(void)                  //         --------------------
{                                   //          --------------------
	unsigned  i,j;										   
	for(i=0;i<200;i++)         //原为 "for(i=0;i<100;i++)        现延时延长 改为200
	{                          //       {
		for(j=0;j<200;j++)     //         for(j=0;j<100;j++)
			{}                 //            {}              "
	}                         //设某位标志,改变状态,测量时间 400MS
}

void  init_time0(void)
{
	TMOD=(TMOD&0xf0)|0x01;
	TL0=-8000;
	TH0=(-8000)>>8;
	TR0=1;                     //开中断,启动定时器5MS后,NUMBER,COLUMN
	ET0=1;                    //从初始值开始数值变动
	EA=1;
}


void  isr_time0(void)  interrupt  1    //在中断里处理数据
{                                        //注意前面DELAY()和number,column初始为0的
	TL0=-8000;                           //关系
	TH0=(-8000)>>8;
                                       
                                      //和<跑马灯> "index%=11"比较
	column=(column+1)%5;               //在400MS期间,每4MS中断一次,
	P1=digit_code[number][column];     //改变字符显示列,循环显示各列
	P3=(0x01<<column);                
}
 
 
/*-----------编译  除错 1 ---选中ASSEMBLY CODE(在列表中)---------------
     assembling STARTUP.A51...compiling 二维数组.c...二维首?c(2): warning C318: can't open file 'stadio.h'                     拼写错,应为"stdio.h"   改!!!!
二维首?C(40): error C141: syntax error near ')' 原为" for(j=0;j<100;j++)                     空语句格式 {}                      ()
二维首?C(44): error C129: missing ';' before 'init_time0' 原为"viod  init_time0(void)"                    拼写错,改为"void  init_time0(void)"
Target not created                                             
   ------------编译  除错 2  ----------------------------                         
Build target 'Target 1'       一错错一片(后)assembling STARTUP.A51...compiling 二维数组.c...二维首?C(40): error C141: syntax error near ')'二维首?C(55): error C132: 'intrrupt': not in formal parameter list     ------------拼错,改为"interrupt"--------
二维首?C(55): error C141: syntax error near '1'二维首?C(57): error C244: 'TL0': can't initialize, bad type or class二维首?C(57): error C132: 'TL0': not in formal parameter list二维首?C(58): error C244: 'TH0': can't initialize, bad type or class二维首?C(58): error C132: 'TH0': not in formal parameter list二维首?C(60): error C279: 'column': multiple initialization二维首?C(60): error C244: 'column': can't initialize, bad type or class二维首?C(60): error C132: 'column': not in formal parameter list二维首?C(61): error C244: 'P1': can't initialize, bad type or class二维首?C(61): error C132: 'P1': not in formal parameter list二维首?C(62): error C244: 'P3': can't initialize, bad type or class二维首?C(62): error C132: 'P3': not in formal parameter list二维首?C(63): error C141: syntax error near '}'Target not created                                             
      ------------编译  除错 3-------OK------------                                                    
                ------------------------                                         
----------------------调试  除错----(波形分析信号设错)---------------------------                                       
  Running with Code Size Limit: 2KLoad "F:\\编程类  试验 调试\\C51语言编程\\二维数组 LED演试  入门P127\\二维数组C51程序\\二维数组实例" LA `IT0___^*** error 34: undefined identifier                                                        
                                                          
                                                          */

⌨️ 快捷键说明

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