基于ARM微处理器的数码管驱动设计
嵌入式ARM键盘接口和七段数码管的控制实验

实验三键盘接口和七段数码管的控制实验一、实验目的1. 学习4X4键盘的与CPU的接口原理2. 掌握键盘芯片HD7279的使用,及8位数码管的显示方法;二、实验内容1. 通过4X4按键完成在数码管上的各种显示功能,以及LCD上显示。
三、实验设备1.EL-ARM-830+教学实验箱,PentiumII以上的PC机,仿真调试电缆。
2. PC操作系统WIN98或WIN2000或WINXP,ADS1.2集成开发环境,仿真调试驱动程序。
四、实验原理键盘和7段数码管的控制实验,是通过键盘的控制芯片HD7279A来完成的。
它的信号线及控制线连接到S3C2410上,驱动线直接连到8位共阴的7段数码管上。
由于其芯片的接口电压是5V的,而S3C2410的接口电压是3.3V,所以,HD7279A的信号、控制线经过CPLD 把电压转换到3.3V,然后送入CPU中。
HD7279是一片具有串行接口的可同时驱动8位共阴式数码管或独立的LED的智能显示驱动芯片。
该芯片同时还可连接多达64键的键盘矩阵,单片即可完成显示键盘接口的全部功能。
内部含有译码器可直接接受BCD码或16进制码并同时具有两种译码方式。
此外还具有多种控制指令如消隐、闪烁、左移、右移、段寻址等,具有片选信号可方便地实现多于8位的显示或多于64键的键盘接口。
HD7279在与S3C2410接口中,它使用了4根接口线。
片选信号#CS(低电平有效),时钟信号CLK,数据收发信号DATA,中断信号#KEY(低电平送出),EL-ARM-830+实验箱与其的接口中,使用了三个通用I/O接口,和一个外部中断,实现了与HD7279A的连接,S3C2410的外部中断接HD7279的中断#KEY,三个I/O口分别与HD7279A的其他控制、数据信号线相连。
HD7279的其他管脚分别接4X4按键和8位数码管。
当程序运行时,按下按键,平时为高电平的HD7279A的#KEY就会产生一个低电平,送给S3C2410的外部中断5请求脚,在CPU中断请求位打开的状态下,CPU会立即响应外部中断5的请求,PC指针就跳入中断异常向量地址处,进而跳入中断服务子程序中,由于外部中断4/5/6/7使用同一个中断控制器,所以,还必须判断一个状态寄存器,判断是否是外部中断5的中断请求,当判断出是外部中断5的中断请求,则程序继续执行,CPU 这时,通过发送#CS片选信号选中HD7279A,再发送时钟CLK信号和通过DATA线发送控制指令信号给HD7279A,HD7279A得到CPU发送的命令后,识别出该命令,然后,扫描按键,把得到键值回送给CPU,同时,在8位数码管上显示相关的指令内容,CPU在得到按键后,有时,程序还会给此键值一定的意义,然后再通过识别此按键的意义,进而进行相应的程序处理。
基于ARM单片机的步进电机控制系统设计

关键词: 控制系统; 单片机; ARM ; 步进电机
中图分类号: TP273
文献标识码: A 文章编号: 1009-9492 (2007) 06-0071-03
1 引言
步进电机是数字控制系统中的一种重要执行元件, 广 泛应用在各种自动化控制系统和机电一体化设备中。目前 打印机、绘图仪、机器人、数控机床等设备都以步进电机 为动力核心。随着步进电机在工业控制系统中的应用不断 增加, 对步进电机的控制系统提出越来越高的要求。
综上所述, 系统对电机驱动和控制步骤如下: (1) 系 统 首 先 由 A D S1.2 作 为 软 件 开 发 工 具 , 在 线 开 发出对步进电机的控制程序, 调试运行成功以后, 再把代 码写到 S3C 44B 0X 开发板的 FLA SH 上。 (2) A R M S3C 44B 0X 发 出 脉 冲 信 号 后 , 再 由 C PLD 分 配 脉 冲 信 号 , C PLD 分 配 后 的 信 号 输 出 到 L298, 由 L298 芯片来驱动和控制电机, 其电路原理如图 2。
(3) 所要用到的表格有以下几种 ①查询表: 是预先建好的静态数据文件, 供编译程序 查询数据, 其目的是将程序与数据文件分离, 便于系统扩 展, 包括指令格式表和中间代码格式表 [6]; ②指令格式表: 是按 PLC 指令的语法特点分别存储指 令操作码、操作数代码和操作数范围, 并建立它们间的索 引关系; ③生成表: 是编译过程中产生的动态数据文件包括逻 辑出错表和中间文件数据表; ④逻辑出错表: 随源程序错误类型的不同而变化, 编 译完成后要将逻辑出错表生成系统错误文件。
步进电机的主要特性如下。 (1) 步 进 电 机 步 距 角 与 脉 冲 数 成 严 格 的 正 比 线 性 关 系, 而不受负载变化的影响。 (2) 步进电机只有周期性的误差, 步进电机运转一周 后没有累积误差。
一种基于ARM芯片驱动显示屏电路设计

一种基于 ARM 芯片驱动显示屏电路设计随着LCD显示技术的迅速发展,LCD显示屏得到了广泛的应用。
一般来说,对于RGB总线接口的数字屏都需要有控制器才能正常显示,本文介绍利用GD32F450处理器设计的一种直接挂载RGB接口数字屏的方法。
引言随着工业技术的不断发展,人机界面的开发及应用空前火热,为了具有比较智能的人机界面,数字显示屏被广泛的应用并逐步代替机械显示屏的使用。
本文介绍一种由GD32F450的TLI总线直接挂载RGB接口屏的方案,只用一个ARM芯片来完成屏的显示而且不会占用全部资源,从而节约硬件成本。
1.系统电路设计处理器选用兆易创新生产的国产芯片GD32F450,GD32F450系列MCU基于200MHz Cortex-M4内核,是GD32F4家族的高性能产品线,具备了超高的计算性能,可以与进口芯片STM32F429IIH6TG完全兼容。
GD32F450配备了TFT-LCD控制器(TLI)和硬件图形加速器IPA (Image Processing Accelerator), 以实现液晶驱动并显著提升显示效果,最高可以支持XGA 10寸1024 x 768像素的RGB TFT 显示。
GD32F450的TLI (TFT-LCD控制器)连接同步的LCD接口,并且为无源LCD提供像素数据、时钟以及时序信号来驱动LCD显示屏。
它支持不同的可编程的时序参数。
内置的DMA可以不断的从系统存储器(如外接的SD RAM里)搬运数据并输出到外部的LCD显示。
TLI接口只负责产生LCD需要的时序,并没有集成RAM。
由于显示高分辨率图形图像所需要的RAM容量较大(通常几百KB以上),不可能直接使用MCU内置的RAM,所以需要外扩一片SDRAM来缓存所需要显示的图像数据。
在这里,SDRAM的作用是LCD的显存。
本设计选用深圳国微的国产同步动态随机存储器SDRAM芯片SM48LC16M16M,容量为128Mbit,是一款高度CMOS电路,可以与MT48LC16M16A2TG-75兼容。
实验四_ARM键盘显示电路驱动程序设计

键盘显示电路驱动程序设计实验目的1、了解ARMC语言程序的结构特点2、了解ARMC语言程序的编写方法3、掌握用ARM编写HD7279控制程序方法实验仪器设备及软件ARM实验箱,计算机,ADS程序开发软件实验原理HD7279A 专用键盘显示电路,真正的单片LED数码管显示和键盘接口芯片,无需外围电路,只需要外接少量的电阻等,即可构成完善的显示、键盘接口电路。
而与CPU的接口采用SPI串行接口方式,使用方便。
可方便的构成64按键,8位数码显示电路(共阴极结构) HD7279A内部含有译码器,可直接受BCD码或16进制数据或七段显示码数据。
此外,还具有多种控制指令,如消隐,闪烁,左移,右移,段寻址等。
具有片选信号,可方便地实现多于8位的显示或多于64键的键盘接口。
HD7279的纯指令:1、复位指令(A4H)当HD7279A收到该指令后,将所有显示清除,所有设置的字符消隐、闪烁等属性也被一起清除。
执行后,芯片的状态与上电时一样。
2、测试指令(BFH)该指令使所有的LED全部点亮,并处于闪烁状态,主要用于测试(检查LED是否坏)3、左移指令(A1H)使所有显示左移一位,消隐及闪烁属性不移位,最右边一位为空(暗)。
如:4、右移指令(A0H)使所有显示右移一位,消隐及闪烁属性不移位,最左边一位为空(暗)。
如:5、循环左移指令(A3H)使所有显示右移一位,消隐及闪烁属性不移位,最左边一位移到最右边。
如:6、循环右移指令(A2H)使所有显示右移一位,消隐及闪烁属性不移位,最右边一位移到最左边。
如:HD7279带数据的指令:1、下载数据按方式0译码命令由两字节构成,前半部为指令。
a2,a1,a0为位地址,D3-D0为数据,译码值如图所示。
2、下载数据按方式1译码指令格式与指令1相同,译码表如下所示。
3、下载数据但不译码指令格式如上图所示。
当指令第二字节的位为1时,相应段点亮。
4、闪烁控制88H此命令控制各数码管的闪烁情况。
基于ARM的嵌入式数字控制系统设计说明书

Joint International Mechanical, Electronic and Information Technology Conference (JIMET 2015)Design of Embedded Numerical Control System Based on ARMDongdong Li, Zhiqin WeiSchool of Mechanical Engineering Guangzhou College of South China University of Technology*************.cnKeywords: ARM; Embedded system; Numerical ControlAbstract. The emergence of embedded technology brought a new technological revolution for the field of modern industrial numerical control. Based on the analysis of embedded technology and computer numerical control systems, this paper discussed the general structure model of embedded numerical control system, analyzed the design method of hardware and software, including design of basic drive module, multi-task in parallel of the system, and so on.IntroductionEmbedded CNC(Computer Numerical Control) system has become an important trend of the development of CNC system. The use of embedded system technology in CNC system not only makes the abundance of CNC system hardware and software resources, but also improves the reliability of the whole CNC, taking advantage of the specificity of embedded system’s software and hardware, as well as its customizability. Embedded CNC combines embedded system technology and traditional CNC technology, with the characteristics of strong function, low cost, small size and so on. In terms of social benefits, embedded CNC can greatly popularize numerical control with industrial prospect [1].Embedded systems provides a flexible and convenient control system for numerical control technology, which can be embedded in the industrial system, capable of continuous long-term reliable operation in the industrial environment for micro and cheap control system. At present, the research and application of embedded systems, has become a new trend.ARM (Advanced RISC Machines) processor is a high performance and low power embedded microprocessor. Transplanting the real-time operating system on the ARM processor can improve the reliability and stability of the system, realize the real-time management and improve the performance of the system.This CNC system uses ARM processor, developing numerical device of high integration, stability, high speed and accuracy.Analysis of Embedded CNC and its General Structural Model DesignCNC system receives code information from input device, and various information and instructions are output after compilation, arithmetic and logic processing by logic circuit or system software of NC, and controls all parts of the machine, provides orderly movements[2].Design of embedded system generally consists of two parts: design of hardware platform and software design. Design of hardware platform includes choice of embedded processors, peripheral circuit design and selection of development tool hardware is also crucial. Then we can do the choice of OS (Operating System) and the development of application. The choice of OS is the key to the entire software design; it relates to the difficulty of system development, system operation stability and reliability, and application development, and so on. Before the operating system starts, system initialization is implemented, initializing the system execution environment, basic equipment. Then the transplant of the operating system, the driver development and finally the application development and testing on the operating system are implemented.The embedded numerical control system is composed of three layers--the hardware layer, the operating system layer and the numerical control software layer. The hardware layer of the embedded NC system is composed of the hardware structure of the ARM processor and the motion control chip.As the first step in the research of Embedded NC system, S3C44B0X processor development board is used, which integrates the ARM processor S3C44B0X, memory, FLASH, ARM memory and so on.The development board also integrates the functions of network and serial port, power and manual reset, which greatly reduces the workload in hardware development. ARM development board and the external circuit, constitute the ARM processor hardware architecture.Operating system layer of embedded CNC system uses Linux, which is an open source code embedded real-time operating system. Linux is a multitasking operating system, which has a feature of being able to be cut according to the needs.Using Linux makes control software of embedded CNC system relatively simple. So the system has the ability of multi task processing and good real-time performance. The operating system layer includes memory management, task management, device management, motion control chip interface, communication interface, etc. In the top is the numerical control system matching software, mainly including the various control functions, such as control function of motion control chip, etc. Hardware Design of Embedded CNCA master-slave dual CPU structure model is used in the embedded numerical control system. The main CPU is ARM processor, which is used in the management of keyboard input, LCD, serial port and network communication, and to control the slave CPU through read and write bus, which is motion control chip, PCL6045, used to complete the complex motion control. The communication between PCL6045 and ARM processor is to read and write several addresses on the bus to carry out instructions and data transmission. In addition, the system's input and output I/O port, keyboard, network and so on is also controlled by the bus. Figure 1 shows the overall structure of the hardware of the embedded CNC system.Fig.1 General Structure of Hardware in Embedded CNCConnection Between PCL6045 and 3C44B0X PCL6045 is a powerful DSP motion control chip in PCL series. PCL/PCD series chip is a special purpose DSP (digital signal processing) motion processor designed for the purpose of stepping and servo control. With its features of powerful, simple and easy to use, excellent quality, and competitive prices, PCL6045 has occupied most of the market in the United States, Europe and Japan, and become the world's first brand. PCL6045 can receive commands from the bus interface or support manual input for real-time motion control, including uniform and variable speed pulse transmission, lifting speed planning, linear or circular interpolation, etc. The highest frequency of the chip output pulse reaches 6.5MHZ. The chip cancontrol four axes interpolation and perform continuous interpolation motion of multi segment line and circular arc.In order to simplify the structure of the software, a function library is built, which is used to manage the operation of the PCL6045 chip. According to the data book of PCL6045 chip and the specific use of the system, the function library includes dozens of functions, such as:1) Parameters setting functions (setting distance, velocity, acceleration, etc.).2) State reading functions (reading the current position, origin and limit switch state, etc.).3) Motion functions (point position motion, continuous motion, circular interpolation, return to zero, etc.).4) Stop and interrupt management functions (rush and deceleration, etc.).The control function library of PCL6045 motion control chip is an important part of the software system.S3C44B0X’s address and data line separation, which has RD, WR, WAIT read and write control signal line.Design of the Basic Drive Module of the System According to the design of system hardware, the basic drive module includes: storage unit, display unit, keyboard unit, I/O unit, D/A unit, A/D unit, serial communication and network communication [3]. Below are the function, design principles and the main interface of the drivers.Storage unit driver: the driver module encapsulates the RAM area, FLASH read / write / removal and other low-level data operations, whose external interface format is divided by byte, word, double word, data block, which is the upper data management module.Display drive unit: display unit driving encapsulates the basic operation of the LCD module, using the basic instruction SED1335 controller provides, provides the basic call interface for display of text, graphics, etc., and encapsulates some commonly used graphic structure in the form of control for the upper software.Keyboard unit driver: the driver module encapsulates the keyboard scan subroutine, and can be invoked by timing routine, by specifying the scan time, the time for eliminating the jitter and providing keyboard encoding table and other parameters.I/O unit driver: input and output driver module, which provides reset operation for some independent I/O interface, and is encapsulated as reading and writing call in the form of control word. Serial communication driver: implements the basic operating functions, such as low-speed data stream transmitting, receiving, transmission, error detection and encryption.Network communication driver: the network card driver implements the protocol of TCP/IP, and establishes a complete network connection and transmission framework.Software Design of Embedded CNCEmbedded CNC software system takes embedded operating system as the core, through its core which is responsible for dynamic management system memory, implements task scheduling, coordinates the communication between tasks using signal, mailbox mechanism. It also implements the communication between tasks, procedures through message queue[4].The system software can be divided into five modules: system boot program Bootloader, embedded operating system kernel, device driver, API(Application Programming Interface) function, system task and application program.Bootloader is a program that runs before the operating system kernel. Through this program, you can initialize the hardware device, set up the boot parameter area, build the mapping graph of the memory space, construct the parameter structure and identify list (the kernel needs to use the boot parameter to identify the root device, page size, memory size), so as to make the system's software and hardware environment in a suitable state.Embedded operating system implements the core functions, such as task scheduling and control of embedded applications. It has the characteristics of compact core, configurable, and closely related with high level application.Device driver provides direct control and the use of the underlying hardware resources, and as a link between the underlying hardware and the upper API function, separating the underlying hardware and API functions, so that the underlying hardware changes will not affect API functions and applications. Therefore it is easy to maintain and upgrade the system only by changing the corresponding hardware drivers.API function provides the user with the basic control of the development and management system interface. Users can directly call the corresponding API functions for the application development based on the actual needs. In this way, not only the complexity of the application development is reduced and the development speeds up, but also the portability of applications is ensured and the convenience for upgrade is realized. [5]The function of system task module is to coordinate the scheduling between the main tasks to ensure the efficiency and real-time performance of the task.A series of specific functions can be realized through the application program. Users write the application according to the actual needs by calling the corresponding API function, the operation of the controlled object, to achieve the required functions. The coordination between application tasks can be implemented with the help of the system's message queue mechanism. [6]Debugging and ConclusionsSystem debugging is carried out in the quilting CNC machine, which includes a main control box with a motor, a tachometer disc and various other sensors.Embedded CNC system is a combination of embedded system and numerical control technology, which has become an important direction in the development of numerical control system. The design develops an embedded CNC system with dual CUP, ARM and DSP. The main CPU is based on the ARM core S3C44B0X. And the slave CPU is PCL6045 motion control chip, which is used to complete the complex motion control. In the software, the free open source Linux system is used as the software platform, and the Linux is improved to meet the real-time requirements of industrial control field. On this basis, the main functional modules of the CNC system were analyzed and designed.AcknowledgmentThe authors would like to thank the Outstanding Young Backbone Teachers Project supported by Guangzhou College of South China University of Technology.References[1] Wang Hujun, “Research on the development of domestic and international numerical control system”,Science Education , vol 2, 2011, p. 179[2] Xu Yizhen, “Embedded CNC milling system research based on ARM and real-time Linux” , Nanjing Aerospace University, 2012, pp.50-55.[3] Samsung Electronics S3C44B0X USER’S MANUAL Revision 1.Korea,Samsung Electronics Co. ,Ltd.[4] Zhou Junjie, He Panfeng, “Design of the real-time multi task software framework based on VxWorks”, Foreign electronic measurement technology, vol. 31(4), 2012, pp. 80-82.[5] He Haibo, “Study on key technologies of intelligent home furnis hing system based on embedded Linux”, Anhui Institute of Technology, 2012.[6] Cao Yuhua, Yu Youpeng, “Research on real-time embedded CNC system based on Xenomai”, Manufacturing Technology and Machine, 2011, (6), pp. 51~55.。
数码管驱动芯片有哪些

数码管驱动芯片有哪些数码管是一种显示设备,它是由多个发光二极管组成的。
为了驱动数码管的显示,需要使用特定的驱动芯片。
下面是一些常见的数码管驱动芯片:1. TM1637:TM1637是一种常用的4位数码管驱动芯片,适用于控制共阳或共阴数码管。
它具有简单的接口和丰富的功能,可以轻松实现数字、字母、符号的显示和控制。
2. TM1650:TM1650是一种集成了键盘扫描和数码管驱动功能的芯片。
它可以同时驱动4位数码管,并且具有内置的键盘扫描功能,可直接与开关矩阵连接,实现灵活的控制。
3. MAX7219:MAX7219是一种广泛使用的8位数码管驱动器,具有独特的串行接口。
它可以同时驱动8位共阳或共阴数码管,并且可以级联多个芯片,实现更多数码管的显示。
4. HT1621:HT1621是一种针对液晶数码管设计的驱动芯片,可以同时驱动4位数码管,同时支持多种显示模式和字符设置。
它具有低功耗特性和简单易用的接口。
5. CD4543:CD4543是一种BCD-7段数码管驱动芯片,适用于显示0-9数字和部分字母。
它具有直接BCD码输入和简单的复位功能。
6. CD4511:CD4511是一种BCD-7段数码管驱动芯片,适用于显示0-9数字和部分字母。
它具有多种输入模式和BCD码转换功能。
7. HT1622:HT1622是一种驱动静态和多功能数码管显示的专用控制器,兼容于HT1621。
它具有低功耗和扫描速度快的特点。
8. MBI5168:MBI5168是一种高亮度LED数码管驱动芯片,适用于控制共阳数码管。
它具有高驱动电流能力和优秀的亮度调节范围。
除了这些常见的数码管驱动芯片外,还有许多其他型号和品牌的芯片可供选择。
根据不同的应用场景和需求,选择合适的数码管驱动芯片非常重要。
基于ARM9的DMA控制器驱动程序的设计

基于ARM9的DMA控制器驱动程序的设计随着嵌入式系统的快速发展,对于数据传输速度和效率的要求也越来越高。
DMA(Direct Memory Access,直接内存访问)控制器在嵌入式系统中起着至关重要的作用。
本文将探讨基于ARM9的DMA控制器驱动程序的设计。
一、DMA控制器的作用和原理DMA控制器是一种硬件设备,用于实现直接内存访问。
它可以在不经过CPU的干预下,直接进行数据传输。
这种方式可以大大提高数据传输速度和效率,减轻CPU的负担。
DMA控制器通过两个寄存器进行配置:源地址寄存器和目的地址寄存器。
源地址寄存器用于指定数据的来源地址,目的地址寄存器用于指定数据的目的地址。
控制器还包括一个计数器,用于指定要传输的数据的长度。
二、DMA控制器驱动程序的设计1. 初始化DMA控制器在设计驱动程序时,首先需要进行DMA控制器的初始化。
初始化的过程包括设置源地址寄存器、目的地址寄存器和计数器的值,以及配置传输模式和中断。
2. 启动数据传输初始化完成后,可以通过启动DMA控制器来开始数据传输。
启动过程中,DMA控制器将根据配置的源地址、目的地址和计数器的值,自动进行数据传输。
传输完成后,控制器会发出中断信号,通知CPU数据传输已完成。
3. 中断处理在驱动程序中,需要对DMA控制器的中断进行处理。
中断处理程序可以根据需要进行相应的操作,例如读取传输完成的数据,或者进行下一次数据传输的配置。
4. 错误处理在数据传输过程中,可能会出现一些错误情况,例如传输超时或数据丢失。
驱动程序需要对这些错误进行处理,例如重新配置DMA控制器或进行错误日志记录。
5. 节省能源为了节省能源,在不需要进行数据传输时,可以将DMA控制器设置为休眠模式。
这样可以减少功耗,并延长嵌入式系统的电池寿命。
三、应用实例基于ARM9的DMA控制器驱动程序在许多嵌入式系统中得到了广泛应用。
例如,在音频处理领域,可以使用DMA控制器实现音频数据的高速传输,提高音频处理的效率。
单片机驱动数码管电路

单片机驱动数码管电路数码管是一种常见的电子显示器件,它可以显示数字、字母和其他特殊字符。
而单片机作为一种集成电路,能够通过编程来控制外部设备的工作,因此可以很方便地用来驱动数码管。
本文将介绍单片机驱动数码管电路的原理和实现方法。
一、数码管的工作原理数码管由若干个发光二极管(LED)组成,每个发光二极管都有两个引脚:一个是正极,用于接收电流;另一个是负极,用于接收控制信号。
数码管通常分为共阳极和共阴极两种类型。
共阳极数码管的正极连接在Vcc(正电源)上,负极通过控制信号接地。
当控制信号接地时,相应的发光二极管会亮起;当控制信号断开连接时,相应的发光二极管会熄灭。
通过控制不同的发光二极管,可以显示不同的数字或字符。
共阴极数码管与共阳极数码管相反,正极通过控制信号接地,负极连接在Vcc上。
二、单片机驱动数码管的原理单片机可以通过IO口输出高低电平来控制数码管的工作。
以共阳极数码管为例,当IO口输出高电平时,相应的数码管发光二极管亮起;当IO口输出低电平时,相应的数码管发光二极管熄灭。
为了实现多位数码管的显示,通常需要使用译码器。
译码器可以将单片机输出的数字信号转换为对应的控制信号,从而实现对数码管的驱动。
常用的译码器有BCD译码器和数码管驱动IC等。
三、单片机驱动数码管的实现方法1. 硬件连接将单片机的IO口与数码管的控制引脚连接。
通过接线将单片机的IO口与译码器的输入引脚相连,然后将译码器的输出引脚与数码管的控制引脚相连。
同时,将数码管的电源引脚与电源连接,确保正极连接在Vcc上,负极连接在GND上。
2. 编程控制在编程时,首先需要定义数码管显示的内容。
可以使用数组或变量来存储需要显示的数字或字符。
然后,将需要显示的内容转换为对应的译码器输入信号,通过单片机的IO口输出给译码器。
最后,通过循环控制,不断更新数码管的显示内容,实现动态显示效果。
四、总结通过单片机驱动数码管电路,可以实现对数码管的灵活控制。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
专业课程设计任务书学生姓名专业班级学号题目基于ARM微处理器的数码管驱动设计课题性质 A 课题来源 D 指导教师同组姓名主要内容1. 利用ARM微处理器实现数码管显示驱动;2. 能够显示0 1 2 3 4 5 6 7 8 9等数字,且循环显示;3. 通过按键改变循环显示速度。
任务要求1. 设计出具体电路,列出所用器件及布线图;2. 画出程序流程图,画出子程序或中断流程图;3. 说明系统工作原理,对系统进行调试;4. 写出课程设计报告。
参考文献1. 嵌入式系统有关教材;2. 电路设计手册;3. 其他资料。
审查意见指导教师签字:教研室主任签字:年月日基于ARM微处理器的数码管驱动设计一、设计要求1、利用ARM微处理器实现数码管显示驱动;2、能够显示0 1 2 3 4 5 6 7 8 9等数字,且循环显示;3、通过按键改变循环显示速度;二、设计方案本次试验选用的芯片为PXA270,使用的是PXA270集成试验箱。
基于Intel XScale架构的PXA270处理器,集成了存储单元控制器、时钟和电源控制器、DMA 控制器、LCD控制器、AC97控制器、I2S控制器、快速红外线通信 (FIR)控制器等外围控制器,可以实现丰富的外围接口功能。
其低电源运行模式以及动态电源管理技术可以有效的降低电源的功耗。
使用试验箱上的4X4的矩阵键盘作为输入,用来控制数码管显示的快慢速度,将需要输出的各个数码管状态从两个数码管中输出。
三、设计原理1、数码管结构七段数码管由8个发光二极管排列组成(包括小数点位)如下图所示:这8个独立的二极管通常被命名:a.b.c.d.e.f.g.h。
h表示小数点。
利用7段数码管能显示所有数字以及部分英文字母。
数码管有2种不同的形式:一种是8个发光二极管的阳极都连一起,成为共阳极8段数码管如图所示:共阳极8段数码管的8个发光二极管的正极一起接VCC,要控制数码管中的某一段亮,比如A段,只须要控制数码管的A脚为低电平就可以了,反之熄灭A段就控制A脚为高电平。
另一种是8个发光二极管的阴极都连在一起,称为共阴极数码管,如图所示:共阴极8段数码管的8个发光二极管的正极一起接GND,要控制数码管中的某一段亮,比如A段,只须要控制数码管的A脚为高电平就可以了,反之熄灭A段就控制A脚为低电平。
2、数码管显示方式数码管的显示方式有静态和动态之分。
分别介绍如下:(1)静态相示方式:当8段数码管显示一个字符时,该字符对应的发光二极管控制信号一直保持有效;静态显示方式的每个数码管都需要一组控制信号。
(2)动态显示方式:动态的多组控制信号,轮流扫描这些数码管,十多个数码管可以同时动态显示(相对人眼)。
该字符对应的发光二极管是轮流点亮的,即控制信号按一定的周期有效,在点亮过程中,点亮时间是很短暂的,所以视觉看到的依然是很稳定的。
3、数码管驱动电路设计以共阳极数码管为例:用处理器的8个GPIO分别控制数码管中的8段发光二极管,这样往GPIO 的引脚送一个低电平就能点亮该引脚对应的一段数码管,由于发光二极管能承受的电流大多是毫安级的,因此还需要外接一个限流电阻。
在实际设计中,处理器一般不是直接用8个I/O 脚来控制数码管的显示,而是通过外接一个译码器来控制。
最常用的译码器是BCD 译码器。
如下图所示。
4、程序设计流程图5、如何让驱动程序加载到内核(1)添加步骤(括号内容为解释):(以添加led.c 驱动程序为例) ①在确定了自己的代码位置的前提下,建立自己的源代码目录,文件,Makefile ,Config.in 等。
(对于本程序中Makefile 文件和Config.in 文件已有,只需添加相关内容即可,无需更改)Makefile 文件:一个工程中的源文件不计其数,其按类型,功能,模块分别放在若干个目录中,makefile 定义了一系列的规则来指定,哪些文件需要先AB C D E F GAD数码管与7段数码管的连接H G F E D C B Acom ``````28Gpio1 Gpio2 Gpio3gpio 81 vcc编译,哪些文件需要后编译,哪些文件需要重新编译,或是进行更复杂的功能操作。
当执行make命令时,便会调用makefile文件,以告诉make命令需要怎样的去编译和连接程序。
Config.in文件:该文件可理解为内核的配置脚本,在执行 make menuconfig 命令时被调用,依靠各子目录的config.in文件,构成整个linux的配置菜单,在内核配置make menuconfig时从config.in中读出菜单,用户选择后保存到.config的内核配置文件中。
在内核编译时,主makefile调用这个.config 文件,就知道了用户的选择。
②将自己的led.c源程序放入内核源码drive/char下③修改driver/charConfig.in文件,把自己的驱动加入内核配置系统中。
在文件中的适当位置(任意,决定了make menuconfig窗口中的所在的位置)添加内容:dep_tristate ‘s3c2410 led support’CONFIG_S3C2410_GPIO_LED $ CONFIG_ARCH_S3C2410代码解释:只要定义了CONFIG_ARCH_S3C2410为y或是m(即在make menuconfig之后的窗口中选择y或是m)character分类下就会出现s3c2410 led support选项,它对应了CONFIG_S3C2410_GPIO_LED的定义。
当定义s3c2410 led support为m,即把驱动程序编译为模块(不会编译到内核)生成.O文件,然后手动用insmod加载。
当定义s3c2410 led support为y,即把驱动程序生成.O文件并且连接到内核,启动时自动加载。
执行make编译时makefile文件会根据obj-m和obj-y编译并连接对应的源码。
如果在配置内核时被驱动编译为模块,则CONFIG_S3C2410_GPIO_LED被定义为m,在makefile脚本对应的obj-m中,就会编译led.o为内核可加载的模块④修改driver/char/makefile文件添加内容:obj-$( CONFIG_S3C2410_GPIO_LED)+=led.o⑤执行命令:make modules(在linux—2.4.18—2410cl下执行)⑥执行命令:make menuconfig⑦配置好后进入开发板执行命令:insmod led.o(2)测试驱动程序①通常测试一个驱动程序都需要相应的应用程序,但对于一些只有标准输入输出例如:open,close(release),read,write等调用的驱动程序,有简单的办法,即使用linux现有的命令例如:cat,echo等实现对设备的访问和控制。
②通过编写应用程序来测试驱动程序6、动态加载驱动1)lsmod 查看是否有驱动程序即.o文件2)insmod led.o 动态添加驱动3)rmmod led 删除驱动详细步骤如下:①建终端,进入arm2410cl/kernel/linux-2.4.18-2410cl②行命令>#make menuiconfig③在窗口中选中“character device,进行相关配置后④执行命令>#make clean(把环境清理干净)⑤make dep (添加相关依赖文件)⑥make modules⑦进入driver/char目录下,查看是否生成.o文件⑧进入开发板cd host/kernel/linux-2.4.18-2410cl/drivers/char⑨执行命令#insmod led.o⑩执行命令lsmod (查看驱动是否添加成功)在开发板找到相应程序,进入该目录下,运行./led将写好的控制源程序(由汇编程序和C程序共同构成),以及makefile文件,放到共享目录下的文件夹中。
进入开发板的相关目录下,执行make命令之后会生成led.bin文件四、设计程序Main.c#include "cvtpxa270.h"unsigned char seg7table[21] = { 0xc0,0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8,0x80, 0x90,0x88, 0x83, 0xc6, 0xa1, 0x86, 0x8e,0xf9, 0xb0, 0x92,0xf8, 0x90};void delay(int count){while(count --);}int Main(int argc, char* argv[]){int i;int ch;int num;Uart_Select(FFUART);Uart_Init(115200);LibCommInit();Uart_Printf("Keyboard Test\r\n");for(i=0;i<0x15;i++){ch=Key_GetKey();switch(ch)case 1:num=num-0.19;break;case 2:num++; break;case 3:num=1; break; /default:break;*((unsigned char *) 0x04006000)= seg7table[i];*((unsigned char *) 0x04007000) = seg7table[i];delay(0xffffff*num);}for(i=0x15;i>=0x00;i--){ch=Key_GetKey();switch(ch)case 1:num=num-0.19;break;case 2:num++; break;case 3:num=1; break;default:break;*((unsigned char *) 0x04006000) = seg7table[i];*((unsigned char *) 0x04007000) = seg7table[i];delay(0xffffff*num);}return 0; }五、调试结果在完成将上述程序烧入系统之后将会在试验箱上看到试验结果,数码管会依次显示数值,并且按下按键数码管的显示频率将会改变。
六、心得体会通过这次课程设计,我学到了不少课本上学不到的知识,我加深了对嵌入式系列知识及其系统的认识,同时也锻炼了自己的动手能力。
此次综合课程设计主要涉及硬件和软件两方面的内容,通过这些我的硬件和软件开发能力都获得了提高,首先硬件方面,基本了解了电子产品的开发流程和所要做的工作,在这次课程设计中,不仅对于以前的上理论课中一些不清楚的地方有了新的认识,对于ARM微处理器有了一定的了解,而且对于如何将理论转化成程序有了些更深刻的体会,编程中处理问题的能力也有所增强。