void LCD_ShowBinNum(unsigned char x, unsigned char y, unsigned int num, unsigned char len);
时间: 2024-05-21 07:13:38 浏览: 156
这是一个函数原型,它的作用是在LCD屏幕上显示二进制数。具体解释如下:
- unsigned char x:二进制数在屏幕上的横坐标位置。
- unsigned char y:二进制数在屏幕上的纵坐标位置。
- unsigned int num:要显示的二进制数。
- unsigned char len:要显示的二进制数的位数。
函数实现的具体细节可能需要看函数的代码实现。
相关问题
解释INTRINS.H Intrinsic functions for C51. Copyright (c) 1988-2010 Keil Elektronik GmbH and ARM Germany GmbH All rights reserved. --------------------------------------------------------------------------*/ #ifndef __INTRINS_H__ #define __INTRINS_H__ #pragma SAVE #if defined (__CX2__) #pragma FUNCTIONS(STATIC) /* intrinsic functions are reentrant, but need static attribute */ #endif extern void _nop_ (void); extern bit _testbit_ (bit); extern unsigned char _cror_ (unsigned char, unsigned char); extern unsigned int _iror_ (unsigned int, unsigned char); extern unsigned long _lror_ (unsigned long, unsigned char); extern unsigned char _crol_ (unsigned char, unsigned char); extern unsigned int _irol_ (unsigned int, unsigned char); extern unsigned long _lrol_ (unsigned long, unsigned char); extern unsigned char _chkfloat_(float); #if defined (__CX2__) extern int abs (int); extern void _illop_ (void); #endif #if !defined (__CX2__) extern void _push_ (unsigned char _sfr); extern void _pop_ (unsigned char _sfr); #endif #pragma RESTORE #endif
这段代码是关于C51芯片的Intrinsic函数的头文件,Intrinsic函数是指直接嵌入到程序中的函数,不需要进行函数调用,在编程中可以提高效率。该文件定义了一些Intrinsic函数,比如_nop_、_testbit_、_cror_、_iror_、_lror_、_crol_、_irol_、_lrol_等等,这些函数可以直接在程序中使用。此外,该文件还定义了一些宏,如SAVE、FUNCTIONS、RESTORE等,用于在编译时控制函数的属性和行为。
#include <reg51.h> #define LCD_DB P0 sbit LCD_RS = P2^0; sbit LCD_RW = P2^1; sbit LCD_EN = P2^2; void init_lcd(); void write_command(unsigned char command); void write_data(unsigned char data); void display_string(unsigned char x, unsigned char y, unsigned char *string); void delay(unsigned int i); void main() { unsigned char i; unsigned char data_buffer[16] = "Hello, World!"; init_lcd(); display_string(0, 0, data_buffer); // ????? SCON = 0x50; TMOD = 0x20; TH1 = 0xFD; TL1 = 0xFD; TR1 = 1; while(1) { // ?????????? while(RI == 0); RI = 0; // ?????????????? data_buffer[0] = SBUF; // ?LCD????? display_string(0, 0, data_buffer); } } void init_lcd() { write_command(0x38); // ????:8????,2???,5x7???? write_command(0x0C); // ????:???,???,??? write_command(0x06); // ????:?????,????,????? write_command(0x01); // ????:????,???????? delay(10); // ??10?? } void write_command(unsigned char command) { LCD_RS = 0; LCD_RW = 0; LCD_DB = command; LCD_EN = 1; delay(5); LCD_EN = 0; } void write_data(unsigned char data) { LCD_RS = 1; LCD_RW = 0; LCD_DB = data; LCD_EN = 1; delay(5); LCD_EN = 0; } void display_string(unsigned char x, unsigned char y, unsigned char *string) { unsigned char i; if(x < 16) { if(y == 0) { write_command(0x80 + x); } else if(y == 1) { write_command(0xC0 + x); } else { return; } } else { return; } for(i = 0; string[i] != '\0' && i < 16 - x; i++) { write_data(string[i]); } } void delay(unsigned int i) { unsigned int j, k; for(j = 0; j < i; j++) { for(k = 0; k < 1000; k++); } }
这是一段基于8051单片机控制的LCD显示程序,可以通过串口输入数据并在LCD上显示。其中使用了函数init_lcd()用于初始化LCD,write_command()用于写入LCD指令,write_data()用于写入LCD数据,display_string()用于在指定位置显示字符串,delay()用于延时。程序通过串口接收数据,将其存储在data_buffer数组中,并在LCD上显示。
阅读全文