proteus中header怎么找

proteus中header怎么找,第1张

proteus中header可以通过在Proteus菜山圆斗单栏中找。

1、在Proteus菜单栏中,选择“Options”(选项)->“Compiler”(编译器),然后点击“Add”(添加)按钮。

2、可以在“Addtoincludesearchpath”(添加到搜索路径中)栏中添加你所需要的头文逗磨件路径,路径中包含的头文腔缓件将会被Proteus自动搜索到。

如果 Proteus Debug 报错,请注意以下几个方面:

1. 检查代码是否有语法错误。如果代码编写不当会导致 Proteus Debug 报错或崩溃。请检查程序的语法,修复错误,然后再次尝试。

2. 检查代码是否调用正确头文件。如果您使用了外部库文件,请确保您已正确地包含了头文件并将其链接到程序中。

3. 确认您使用的 Proteus 版本与 Proteus Debug 兼容。如果您使用的 Proteus 版本与 Proteus Debug 不兼容,可能会导致 Proteus Debug 报错。尝试使用正确的版本。

4. 确认 Proteus Debug 是否安装正确。检查您是否已经正确安装 Proteus Debug 插毁兆件,并将其与 Proteus 集成。

5. 确认您正在使用的目标硬件模拟器是否受支持。Proteus 支持各种硬件模拟器,但是可能有些模拟器无法与 Proteus Debug 正常工作。请确认您使用的目标硬件模拟器与 Proteus Debug 兼容。

如果您检查敬姿以上问题后仍然无法解决,可以尝试重新安装 Proteus Debug,或者联系 Proteus 官方技术支持。希纤稿租望这些信息能够帮到您。

几点说明:

1.主要是分以下几个模块写的:SHT10,LCD1602,主函数,头文件。

2.每支SHTxx传感器都在25℃(77 °F)和 3.3V条件下进行过标定并且完全符合精度指标.因为考虑到实际硬件5V的电压比较好 *** 作,所以SHT10用的精度采用的为5V时的参数。其他的都采取默认值(14bit湿度, 12bit 温度)。

3.SHT10中所以部分我都编颤源余写了。有的部分在本次程序中没用到,也可以作为参考。

4.所有程序都已经加了注释,且有仿真图。

5.个人认为还可以在此基础上添加个中断。

6.程序编写keil 4 ,仿真 protues7.5

/***********************************************************************************************************************************************************/

头文件(tou.h):

#ifndef __TOU_H__

#define __TOU_H__

#include<reg52.h>

#include <intrins.h>

//#include <math.h>    //Keil library

#define uchar unsigned char

enum {TEMP,HUMI}

sbit DATA = P1^7

sbit SCK = P1^6

sbit LcdRs = P2^4

sbit LcdRw = P2^5

sbit LcdEn = P2^6

sfr DBPort = 0x80     //P0=0x80,P1=0x90,P2=0xA0,P3=0xB0.数据端口

/********     DS1602函数声明     ********/

void LCD_Initial()

void GotoXY(unsigned char x, unsigned chary)

void Print(unsigned char *str)

void LCD_Write(bit style, unsigned charinput)

/********     SHT10函数声明      ********/

void s_connectionreset(void)

char s_measure(unsigned char *p_value,unsigned char *p_checksum, unsigned char mode)

void calc_sth10(float *p_humidity ,float*p_temperature)

//float calc_dewpoint(float h,float t)

#endif

/***********************************************************************************************************************************************************/

SHT10程序(SHT10.c):

#include<tou.h>

#define noACK 0                        //继续传输数据,用于判断是否结束通讯

#define ACK   1            //结束数据传输;

//地址 命令  读/写

#define STATUS_REG_W 0x06   //000  0011    0

#define STATUS_REG_R 0x07   //000  0011    1

#define MEASURE_TEMP 0x03   //000  0001    1

#define MEASURE_HUMI 0x05   //000  0010    1

#define RESET        0x1e  //000   1111    0

//写字节程序

char s_write_byte(unsigned char value)

{

unsignedchar i,error=0

for(i=0x80i>0i>>=1)            //高位为1,循环右移

{

if(i&value) DATA=1          //和要发送的数相与,结果为发送的位

       else DATA=0

       SCK=1

       _nop_()_nop_()_nop_()        //延时3us

       SCK=0

}

DATA=1                    裂漏       //释放数据线

SCK=1          茄滚                

error=DATA                       //检查应答信号,确认通讯正常

_nop_()_nop_()_nop_()

SCK=0

DATA=1

returnerror                     //error=1 通讯错误

}

//读字节程序

char s_read_byte(unsigned char ack)

//----------------------------------------------------------------------------------

{

unsignedchar i,val=0

DATA=1                           //释放数据线

for(i=0x80i>0i>>=1)             //高位为1,循环右移

{

SCK=1

       if(DATA) val=(val|i)        //读一位数据线的值

       SCK=0

}

DATA=!ack                        //如果是校验,读取完后结束通讯;

SCK=1

_nop_()_nop_()_nop_()          //延时3us

SCK=0

_nop_()_nop_()_nop_()

DATA=1                           //释放数据线

returnval

}

//启动传输

void s_transstart(void)

// generates a transmission start

//      _____         ________

// DATA:      |_______|

//          ___     ___

// SCK : ___|   |___|  |______

{

  DATA=1SCK=0                   //准备

  _nop_()

    SCK=1

  _nop_()

  DATA=0

  _nop_()

    SCK=0

     _nop_()_nop_()_nop_()

  SCK=1

  _nop_()

    DATA=1

    _nop_()

  SCK=0

}

//连接复位

void s_connectionreset(void)

// communication reset: DATA-line=1 and atleast 9 SCK cycles followed by transstart

//      _____________________________________________________         ________

// DATA:                                                     |_______|

//         _    _    _   _    _    _   _    _    _       ___     ___

// SCK : __| |__| |__| |__| |__| |__| |__||__| |__| |______|   |___|   |______

{

unsignedchar i

DATA=1SCK=0                    //准备

for(i=0i<9i++)                  //DATA保持高,SCK时钟触发9次,发送启动传输,通迅即复位

{

SCK=1

       SCK=0

}

s_transstart()                   //启动传输

}

//软复位程序

char s_softreset(void)

// resets the sensor by a softreset

{

unsignedchar error=0

s_connectionreset()              //启动连接复位

error+=s_write_byte(RESET)       //发送复位命令

returnerror                     //error=1 通讯错误

}

/*读状态寄存器

char s_read_statusreg(unsigned char*p_value, unsigned char *p_checksum)

//----------------------------------------------------------------------------------

// reads the status register with checksum(8-bit)

{

unsignedchar error=0

s_transstart()                   //transmission start

error=s_write_byte(STATUS_REG_R)//send command to sensor

*p_value=s_read_byte(ACK)        //read status register (8-bit)

*p_checksum=s_read_byte(noACK)   //read checksum (8-bit)

returnerror                     //error=1 incase of no response form the sensor

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/8173458.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-14
下一篇 2023-04-14

发表评论

登录后才能评论

评论列表(0条)

保存