1 / 44

软硬件设计基础知识 --- 软件设计

软硬件设计基础知识 --- 软件设计. 74HC 244. 1A1 1Y1 1A2 1Y2 1A3 1Y3 1A4 1Y4 2A1 2Y1 2A2 2Y2 2A3 2Y3 2A4 2Y4 1G 2G. 74HC 245. 内容回顾. A0 B0 A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7

rianna
Download Presentation

软硬件设计基础知识 --- 软件设计

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 软硬件设计基础知识---软件设计

  2. 74HC 244 1A1 1Y1 1A2 1Y2 1A3 1Y3 1A4 1Y4 2A1 2Y1 2A2 2Y2 2A3 2Y3 2A4 2Y4 1G 2G 74HC 245 内容回顾 A0 B0 A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7 E DIR 0 0 1 GNDD

  3. 内容回顾 0 1 1 1 X X 1 0 1 X X 1 0 0 0 1 1 D触发器

  4. A Y0 B Y1 C Y2 Y3 Y4 E1 Y5 E2 Y6 E3 Y7 74HC138 内容回顾 1 1 1 1 1 0 0 1 0 1 0 1 1 1

  5. 系统控制信号中,AEN、 、 的作用? 答:AEN(地址允许):输出。 IOR、 IOW 1 DMA周期 AEN= 0 CPU周期 内容回顾 引脚信号基本上可分为几类? 答:电源信号、地址总线、数据总线、系统控制信号、CPU控制信号

  6. (I/O读):输出 (I/O写):输出 低电平有效, 外设 CPU CPU 外设 低电平有效, IOR IOW 内容回顾 CPU控制信号中,RDY的作用? 答:RDY(输入输出通道准备好):输入 当该引脚输入低电平时,系统等待。

  7. 新课导入: 为什么要进行软件编程? 应使用何种语言进行软件编程?

  8. C语言函数库常用函数

  9. 1.inportb() 原型:inportb(int port) 头文件:dos.h 功能:读接口数据时使用,从指定的端 口port,读取一个字节的数据,返回值 为所读取到的数据。

  10. main() {clcscr(); unsigned char c; c=inportb(0x250); //从该端口读一个字节数据赋给c printf(“data=%02x”,c); return 0; } • 实例 #include”conio.h”//函数clrscr的头文件 #include”dos.h”//函数inportb的头文件 #include”stdio.h”//函数printf的头文件 程序能否运行?

  11. 结果: data=ff 若输出格式为%03d,结果为? 若输出格式为%03o,结果为?

  12. 2.outportb() 原型:void outportb(int port, unsigned char value) 头文件:dos.h 功能:将一个字节的数据输出到输出口port 上。

  13. 实例 #include”dos.h” //函数inportb的头文件 main() { outportb(0x250,0x55); //将数据0x55送至端口 }

  14. 结果 十六进制数0x55被写入到地址为0x250的端口中。

  15. 3.clrscr() 原型:void clrscr(void); 头文件:conio.h 功能:将屏幕清除为空白,光标回到起点即 左上角位置处。

  16. 实例 #include”conio.h” //函数clrscr的头文件 main() { clcscr(); printf(“Hello world”); }

  17. 4.getch() 原型:int getch(void) 头文件:conio.h 说明:用来暂停程序的执行,等待使用者从 键盘输入。

  18. 实例 #include”conio.h” //函数getch的头文件 main() { while(1) { printf(“this is a test……”); getch(); } }

  19. 5.kbhit() 原型:int kbhit(void) 头文件:conio.h 功能:用来检查是否有按键。若有,返回非 零值。否则返回0。 可用来“触发”一个程序,例如当按键时,输出一个字符串hello。

  20. 实例 #include”conio.h” //函数kbhit的头文件 main() { while(1) { if(kbhit()) { printf(“hello”); break; } } }

  21. 6.printf() 原型:int printf(const char *format,……) 头文件:stdio.h 功能:将各种数值或字符串送到输出设备, 一般指屏幕。

  22. 实例 #include”stdio.h” //函数printf的头文件 main() { unsigned char c; c=0x55; printf(“data c=%d\n”,c); printf(“data c=%x\n”,c); printf(“data c=%o\n”,c) }

  23. 结果 data c=85 data c=55 data c=125

  24. 7.puts() 原型:int puts(char *string) 头文件:stdio.h 功能:将字符串输出,并在最后送出换行符 ‘\n’

  25. 实例: #include”stdio.h” //函数puts的头文件 main() { puts(“this is a test……”); }

  26. 8.sprintf() 原型:int sprintf(char *buffer,const char *format,……) 头文件:stdio.h 功能:将数据或字符串按指定格式存储在存 储器缓冲区buffer内。

  27. 实例 #include”stdio.h” //函数sprintf的头文件 main() { char mess[30]; unsigned char a,b; a=0x55;b=0xaa; sprintf(mess,”data a=%x b=%x”,a,b); puts(mess); }

  28. 结果 a=55 b=aa

  29. 9.scanf() 原型:int scanf(const char *format, ……) 头文件:stdio.h 功能:按指定格式输入数据,并存放在指定 的变量内。

  30. 实例 #include”stdio.h” //函数scanf的头文件 main() { unsigned char c; printf(“please input data?”) scanf(“%d”,&c); printf(“input data c=%d\n”,c)

  31. 10.gotoxy() 原型:void gotoxy(int x, int y); 头文件:conio.h 功能:将光标移到屏幕文本窗口坐标(x,y) 处。

  32. 实例 #include ”conio.h” //函数gotoxy的头文件 main() { clrscr(); gotoxy(10,10); printf(“good morning!”) }

  33. 11.delay() 原型:void delay(unsigned milisecond) 头文件:dos.h 功能:函数调用后暂停程序执行几个毫秒 注意:此函数所延迟的时间会随着电脑CPU执行 速度不同而略有差异。

  34. 实例 #include ”dos.h” //函数delay的头文件 main() { int i; for(i=0;i<5;i++) { printf(“hello\n”); delay(1000); } }

  35. 12 sound() 原型:void sound(unsigned frequency) 头文件:dos.h 功能:将PC的喇叭打开,并以所指定的频率 发声。

  36. 13 nosound() 原型:void nosound(void) 头文件:dos.h 功能:关掉PC的喇叭,使声音消失。

  37. 实例 #include ”dos.h” //函数sound和nosound的头文件 main() { while(1) { sound(1000); delay(500); nosound(); delay(700); if(kbhit()) break; } }

  38. 小结 inportb() outportb() delay() sound() nosound() scanf() printf() puts() sprintf() stdio.h dos.h clrscr() getch() kbhit() conio.h

  39. 大家已经完成了本章的学习。下面,让我们检验学习效果吧~~大家已经完成了本章的学习。下面,让我们检验学习效果吧~~

  40. 1、将各种数值及字符串依特定的格式送到标准的输出设备(一般指屏幕)的函数是1、将各种数值及字符串依特定的格式送到标准的输出设备(一般指屏幕)的函数是 ( ) A : scanf B:printf C :puts D :sprintf B 2、下面控制软件哪个不是程序设计可以用到的( ) A.汇编 B. C语言 C.机器语言 D.常用C语言接口函数 C

  41. 3、用来暂停程序的执行,并等待使用者由键盘输入的C语言语句是( ) A: getch() B :inportb () C :outportb() D: printf() A 4、将一字节的数据输出到输出口port上的函数名是 ( )。 答案:Outportb

  42. 5、使用outportb ( )函数时要包含( )头文件。 答案:dos.h 6、使用intportb ( )函数时要包含( )头文件。 答案:dos.h

  43. 7、将屏幕清除为空白,光标回到起点即左上角位置处的C语言函数名是 ( )。 答案:clrscr

More Related