0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內(nèi)不再提示

Proteus:簡易示波器

Harmony&嵌入式學習 ? 來源:Harmony&嵌入式學習 ? 作者:Harmony&嵌入式學 ? 2023-06-14 11:35 ? 次閱讀

視頻鏈接:https://www.bilibili.com/video/BV1sr4y1C7tH

pYYBAGSJNVqAVd_sAAFQLSkZtBE712.pngpYYBAGSJNWGAemFmAARCyOnG4UU501.pngpoYBAGSJNWeAII6aAAFbdaTb3xE825.pngpYYBAGSJNW2ANOfGAAJCXhm_3tw495.png
#include "reg52.h"			 //此文件中定義了單片機的一些特殊功能寄存器
#include 
#define uchar unsigned char
#define uint  unsigned int
#define ulong unsigned long
typedef unsigned int u16;	  //對數(shù)據(jù)類型進行聲明定義
typedef unsigned char u8;

sbit CLK=P3^3;//定義時鐘信號口
sbit DIN=P3^1;//定義2543數(shù)據(jù)寫入口
sbit DOUT=P3^0;//定義2543數(shù)據(jù)讀取口
sbit CS=P3^2;//定義2543片選信號口

#define LCD_databus P0 //LCD12864的8位數(shù)據(jù)口

sbit RS=P2^2; 	//RS為0---命令;1----數(shù)據(jù) 
sbit RW=P2^1; 	//RW為1---寫;0---讀 
sbit EN=P2^0; 	//使能端 
sbit CS1=P2^4; 	//片選1低電平有效,控制左半屏 
sbit CS2=P2^3; 	//片選1低電平有效,控制右半屏 
ulong volt;//測量的電壓值
ulong Result;

unsigned char code da[]={/*--  文字:  大  --*/
/*--  楷體_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/
0x00,0x00,0x40,0x40,0x40,0x40,0xFF,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x00,
0x00,0x20,0x10,0x08,0x04,0x03,0x00,0x01,0x02,0x04,0x08,0x10,0x30,0x20,0x20,0x00};


unsigned char code BMP[][64]={/*--  調(diào)入了一幅圖像:D:Desktop12848坐標.BMP  --*/
/*--  寬度x高度=128x48  --*/
0X00,0X17,0X15,0X1D,0X00,0X02,0XFE,0X06,0X02,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X07,0X04,0X1F,0X00,0X00,0XFF,0X04,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X15,0X15,0X1F,0X00,0X00,0XFF,0X04,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X0E,0X8B,0X0B,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0XC0,0X00,0X0F,0X00,0XC0,0X00,0XFF,0X02,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X01,0X02,0X01,0X00,0X78,0X4B,0X7A,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,
0XFB,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0XEA,0XAA,0XBA,0X02,0X02,0X02,0X02,
0X02,0X02,0XA2,0XAA,0XFA,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X3A,0X23,0XFA,0X02,
0X02,0X02,0X02,0X02,0X02,0X02,0XBA,0XAB,0XEA,0X02,0X02,0X02,0X02,0X02,0X02,0X02,
0XFA,0XAB,0XEA,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X0A,0X0B,0XFA,0X02,0X02,0X02,
0X02,0X02,0X02,0X02,0XFA,0XAB,0XFA,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0XBA,0XFA,
0X02,0X02,0X02,0X02,0X02,0X02,0XFA,0X02,0XFB,0X8A,0XFA,0X02,0X02,0X02,0X02,0X02,
0X02,0XFA,0X03,0XFA,0X02,0X02,0X02,0X02,0X07,0X00,0X00,0X00,0X00,0X00,0X02,0X02,
};


void Read_busy()//讀“忙”函數(shù)-----數(shù)據(jù)線的最高位DB71則busy		
{
	P0=0x00;
   	RS=0;  
   	RW=1; 
	EN=1;
	while(P0 & 0x80);
	EN=0;
}

void write_LCD_command(uchar value)	//寫命令函數(shù) 
{
   Read_busy();						//對LCD的每次讀寫都要讀忙 
   RS=0;	 						//選擇命令 
   RW=0; 							//讀操作 
   LCD_databus=value;
   EN=1;							//EN由1----0鎖存有效數(shù)據(jù) 
   _nop_();
   _nop_(); 
   EN=0;
}

void write_LCD_data(uchar value)//寫數(shù)據(jù)函數(shù)	
{
   Read_busy();
   RS=1; 						//選擇數(shù)據(jù) 
   RW=0;	
   LCD_databus=value;
   EN=1;						//EN由1----0鎖存有效數(shù)據(jù) 
   _nop_();		
   _nop_();
   EN=0;
}

uchar Read_LCD(void)			//讀數(shù)據(jù)函數(shù) 
{
	uchar value;
	Read_busy();
	LCD_databus=0xFF;			//先進行一次空讀操作 
	RS=1;
	RW=1;
	EN=1;
	_nop_();
	_nop_();
	EN=0;
	
	LCD_databus=0xFF;			//讀取真正的數(shù)據(jù) 
	RS=1;
	RW=1;
	EN=1;
	value=LCD_databus;
	_nop_();
	_nop_();
	EN=0;
	
	return value; 
}

void Set_page(uchar page)		//設置“頁”LCD12864共8頁,一頁是8行點陣點	
{
  page=0xb8|page; 				//頁的首地址為0xB8
  write_LCD_command(page);
}

void Set_line(uchar startline)  //設置顯示的起始行	   
{
  startline=0xC0|startline;     //起始行地址為0xC0 
  write_LCD_command(startline); //設置從哪行開始:共0--63;一般從0 行開始顯示
}

void Set_column(uchar column)	//設置顯示的列	
{
  column=column &0x3f; 			//列的最大值為64
  column= 0x40|column; 			//列的首地址為0x40 
  write_LCD_command(column);	//規(guī)定顯示的列的位置 
}

void SetOnOff(uchar onoff)		//顯示開關函數(shù):0x3E是關顯示,0x3F是開顯示   
{
	onoff=0x3e|onoff; 			//onoff:1---開顯示;0---關顯示
	write_LCD_command(onoff);
}

void SelectScreen(uchar screen)	//選擇屏幕 
{ 						 
   switch(screen)
   { 
   	 case 0: CS1=0;CS2=0;break; //全屏     
     case 1: CS1=0;CS2=1;break;//左半屏        
     case 2: CS1=1;CS2=0;break;//右半屏       
     default:break; 
   }
}

void ClearScreen(uchar screen)	//清屏函數(shù)  
{ 	
     uchar i,j;
     SelectScreen(screen);		//0--全屏;1---左半屏;2---右半屏 
	 for(i=0;i>3);  		//計算出該點屬于哪個字節(jié) 
	x_bit=y-(x_byte63)				//x>63則顯示在右半屏 
	{
		SelectScreen(2);
		x=x-64;
	}
	else					//顯示在左半屏 
	{
		SelectScreen(1); 
	}
	Set_page(x_byte);		//設置行地址 
	Set_column(x);			//設置列地址
 	Temp_data=Read_LCD();	//先讀出沒打點前LCD中的數(shù)據(jù) 
	switch(color)
	{
		case 0x01 : Temp_data &= ~(1=1;
	volt=ad;//取走轉換結果
	volt=volt*1221;//例子的滿量程為5V,轉換分辯率為12位(2的12次方=4096) 。即最大值是255,5/4096=1221mV,即例子中的1V代表實際1221mV        
}

void delay(uchar ms) 
{  // 延時子程序 
uchar i; 
while(ms--) 
{ 
  for(i = 0;i
審核編輯:湯梓紅
);break;>
聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權轉載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內(nèi)容侵權或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 示波器
    +關注

    關注

    113

    文章

    6246

    瀏覽量

    184940
  • 寄存器
    +關注

    關注

    31

    文章

    5343

    瀏覽量

    120348
  • Proteus
    +關注

    關注

    79

    文章

    1692

    瀏覽量

    106573
收藏 人收藏

    評論

    相關推薦

    Proteus教程:簡易電壓表

    Proteus教程:簡易電壓表
    的頭像 發(fā)表于 06-14 11:33 ?5373次閱讀
    <b class='flag-5'>Proteus</b>教程:<b class='flag-5'>簡易</b>電壓表

    【assingle分享】proteus仿真之a(chǎn)vr簡易示波器仿真

    `proteus仿真之a(chǎn)vr簡易示波器仿真`
    發(fā)表于 03-30 15:23

    書籍教程:Proteus簡易教程

    本資料是關于Proteus.簡易教程的下載,有需要的可以下載看看
    發(fā)表于 07-26 23:16

    求基于單片機的簡易示波器的課程設計包括proteus仿真

    求基于單片機的簡易示波器的課程設計包括proteus仿真
    發(fā)表于 06-22 10:20

    基于51單片機的簡易示波器仿真——》Proteus7.5仿真源文件+C語言源工程文件

    基于51單片機的簡易示波器仿真——》Proteus7.5仿真源文件+C語言源工程文件;一切來自互聯(lián)網(wǎng),無私分享!
    發(fā)表于 04-14 10:08

    基于AVR的簡易示波器設計

    基于AVR的簡易示波器設計:介紹了以AVR單片機ATmega16為核心,采用前端信號調(diào)理電路、程控增益放大器以及波形顯示LCD(GDM12864A)實現(xiàn)的一個簡易示波器。并給出該系統(tǒng)設
    發(fā)表于 05-26 23:41 ?97次下載

    基于FPGA的雙通道簡易可存儲示波器設計

    基于FPGA的雙通道簡易可存儲示波器設計:本文介紹了一種基于FPGA的采樣速度60Mbit/s的雙通道簡易數(shù)字示波器設計,能夠?qū)崿F(xiàn)量程和采樣頻率的自動調(diào)整、數(shù)據(jù)緩存、顯示以及與計算機
    發(fā)表于 09-29 10:45 ?110次下載

    簡易示波器時基發(fā)生器

    簡易示波器時基發(fā)生器 NE555
    發(fā)表于 09-29 11:49 ?956次閱讀
    <b class='flag-5'>簡易</b><b class='flag-5'>示波器</b>時基發(fā)生器

    Proteus示波器使用技巧

    Proteus示波器使用技巧 左下角
    發(fā)表于 03-21 18:46 ?2.8w次閱讀
    <b class='flag-5'>Proteus</b>中<b class='flag-5'>示波器</b>使用技巧

    基于STM32的簡易示波器設備驅(qū)動的研究

    基于STM32的簡易示波器設備驅(qū)動的研究
    發(fā)表于 11-06 17:04 ?68次下載

    Proteus示波器簡介

    Proteus示波器的操作 簡介 此簡介基于 proteus7.8 版本
    發(fā)表于 03-22 11:19 ?15次下載

    簡易電子示波器_陳鵬飛

    簡易電子示波器_陳鵬飛。
    發(fā)表于 05-05 11:01 ?30次下載

    簡易數(shù)字存儲示波器設計

    設計一簡易數(shù)字存儲示波器簡易DSO)。
    發(fā)表于 03-18 15:20 ?412次下載
    <b class='flag-5'>簡易</b>數(shù)字存儲<b class='flag-5'>示波器</b>設計

    基于stm32mini開發(fā)板的簡易函數(shù)發(fā)生器和簡易示波器

    基于stm32 mini開發(fā)板的簡易示波器
    發(fā)表于 01-17 10:01 ?35次下載
    基于stm32mini開發(fā)板的<b class='flag-5'>簡易</b>函數(shù)發(fā)生器和<b class='flag-5'>簡易</b><b class='flag-5'>示波器</b>

    基于LabVIEW的簡易虛擬示波器設計

    基于LabVIEW的簡易虛擬示波器設計方法。
    發(fā)表于 04-06 15:33 ?126次下載