随笔分类 -  c语言

上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 29 下一页
摘要:串口通讯中断应用12M晶振 波特率2400 连接好串口或者usb转串口至电脑,下载该程序,打开电源 打开串口调试程序,将波特率设置为2400,无奇偶校验 晶振12MHz,发送和接收使用的格式相同,如都使用 字符型格式,按复位重启程序,可以看到接收到 UART test,请在发送区输入任意信 然后在发 阅读全文
posted @ 2021-08-17 08:15 myrj 阅读(330) 评论(0) 推荐(0)
摘要:serve.h /* funtion:automatic download explanation: switch:#define _DOWNLOAD_(before #include"serve.h") remember to use uart_init before! */ #ifdef _DO 阅读全文
posted @ 2021-08-17 08:07 myrj 阅读(355) 评论(0) 推荐(0)
摘要:void Timer0Init(void) //50毫秒@11.0592MHz { AUXR &= 0x7F; //定时器时钟12T模式 TMOD &= 0xF0; //设置定时器模式 TL0 = 0x00; //设置定时初值 TH0 = 0x4C; //设置定时初值 TF0 = 0; //清除TF 阅读全文
posted @ 2021-08-15 15:09 myrj 阅读(238) 评论(0) 推荐(0)
摘要:1头文件:HexLexer.h #ifndef _HEXLEXER_H_ #define _HEXLEXER_H_ #include <cstdio> #include <cstring> #include <cstdlib> /* Intel Hex文件解析器V1.0 Hex文件的格式如下: Re 阅读全文
posted @ 2021-08-15 11:58 myrj 阅读(757) 评论(0) 推荐(0)
摘要:#include <stdio.h> int jcws(int a); int main() { int c=1080; c=jcwsa(c); printf("%d\n",c); getchar(); } //不完美:最末不能是连续的0 int jcws(int a) { int b=a,i; f 阅读全文
posted @ 2021-08-13 07:29 myrj 阅读(255) 评论(0) 推荐(0)
摘要:首先显示”时.分“,K1时增加,K2分增加(如果不修改时分默认5分钟:300秒倒计时) K3开始倒计时,显示秒倒计时,到时报警BEEP K4停止报警,并返回到”时分“状态,又可以设置倒计时时间,来回循环 #include<reg51.h> #define uchar unsigned char; # 阅读全文
posted @ 2021-08-11 10:26 myrj 阅读(594) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <math.h> /* C 语言不允许返回一个完整的数组作为函数的参数。但是,可以通过指定不带索引的数组名来返回一个指向数组的指针。如果您想要从函数返回一个一维数组,必须声明一个返回指针的函数,如下: int * myFunction() { 阅读全文
posted @ 2021-08-11 06:07 myrj 阅读(1361) 评论(0) 推荐(0)
摘要:一、c 语言中字符数组和数字的相互转换函数; 相关函数:atof atoi,atol, strtod,strtol,strtoul 在头文件stdlib中 #include<stdlib.h> (1)atof (将字串转换成浮点型数) ascii to floating 的缩写 char *str 阅读全文
posted @ 2021-08-11 06:01 myrj 阅读(1680) 评论(0) 推荐(0)
摘要:#include<reg51.h> #define uchar unsigned char; #define uint unsigned int; uchar position; uchar tt,bz1=0,bz2=0,bz3=0; char buffer [3]; uint second,n; 阅读全文
posted @ 2021-08-10 22:06 myrj 阅读(488) 评论(0) 推荐(0)
摘要:#include <stdio.h> int main() { int arr[] = {1,2,3,4,5}; int length = sizeof(arr)/sizeof(int); printf("%d\n",length); getchar(); } 阅读全文
posted @ 2021-08-10 16:18 myrj 阅读(538) 评论(0) 推荐(0)
摘要:1.字符数组赋值:char c1[20] = "women"; 2。将数转为字符赋值给数组 #include <stdio.h> #include <cstdlib> #include <stdlib.h> int main() { char c1[20] = "women"; int num=10 阅读全文
posted @ 2021-08-10 15:32 myrj 阅读(371) 评论(0) 推荐(0)
摘要:uchar code table1[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//0--9uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x 阅读全文
posted @ 2021-08-10 13:34 myrj 阅读(552) 评论(0) 推荐(0)
摘要:#include<reg51.h> #define uchar unsigned char; #define uint unsigned int; uchar position; uchar tt,bz1=0,bz2=0,bz3=0; uint second; uchar minute; uchar 阅读全文
posted @ 2021-08-10 13:29 myrj 阅读(410) 评论(0) 推荐(0)
摘要:#include<reg51.h> #define uchar unsigned char; #define uint unsigned int; uchar position; uchar tt,bz1=0,bz2=0,bz3=0; uchar second; uchar minute; ucha 阅读全文
posted @ 2021-08-10 13:06 myrj 阅读(240) 评论(0) 推荐(0)
摘要:#include<reg51.h> #define uchar unsigned char; #define uint unsigned int; uchar position; uchar tt,bz1=0,bz2=0; uchar second; uchar minute; uchar hour 阅读全文
posted @ 2021-08-10 12:12 myrj 阅读(324) 评论(0) 推荐(0)
摘要:uchar flag=0; void key() //按键判断程序 { if(key1==0) //判断是否按下键盘 { delay(10); //延时,软件去干扰 if(key1==0) //确认按键按下 { flag=1 } while(key1==0); } if(key2==0) //判断是 阅读全文
posted @ 2021-08-10 08:30 myrj 阅读(1363) 评论(0) 推荐(0)
摘要:#include<reg51.h> #include <intrins.h> char LED; void delay(unsigned int i) { unsigned char j; for(i; i > 0; i--) for(j = 255; j > 0; j--); } main() { 阅读全文
posted @ 2021-08-08 17:35 myrj 阅读(806) 评论(0) 推荐(0)
摘要:#include <reg52.h> #include<intrins.h> sbit key1=P3^2; sbit key2=P3^3; sbit key3=P3^4; sbit key4=P3^5; typedef unsigned int uint; typedef unsigned cha 阅读全文
posted @ 2021-08-08 17:09 myrj 阅读(691) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <math.h> #define MAXCHAR 101 /*最大允许字符串长度*/ int char_to_num(char ch); /*返回字符对应的数字*/ char num_to_char(int num); /*返回数字对应的字符* 阅读全文
posted @ 2021-08-08 11:21 myrj 阅读(165) 评论(0) 推荐(0)
摘要:b=a<<n 等价于b=a*2^n(左移后是左移前的2^n倍:变大) b=a>>n 等价于b=a/2^n(右移前是右移后的2^n倍 变小)说个容易记的左移n位就是将数转为二进制后 右面加n个零 左面的n位舍弃右移n位就是将数转为二进制后 左面加n个零 右面的n位舍弃 在单片机中控制LED灯假设低电平 阅读全文
posted @ 2021-08-06 09:50 myrj 阅读(1664) 评论(0) 推荐(0)

上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 29 下一页