完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,
我有一个问题:如何用I2C实现CY8C27 43-24PXI中的SHT10湿度传感器?我读了很多数据表等,但我还是不知道怎么做。 谢谢大家的帮助。 以上来自于百度翻译 以下为原文 Hello , I have got question about : How can I implementation SHT10 humidity sensor in CY8C27443-24PXI using I2C ? I read a lot of datasheet etc. but I still do not know how. Thanks for all help. |
|
相关推荐
46个回答
|
|
忘记添加
在3271的用户指南中有一个节点配置示例 对于热敏电阻固件,您可以遵循。 问候,Dana。 以上来自于百度翻译 以下为原文 Forgot to add - In the user guide for 3271 there is a node configuration example for the thermistor firmware that you can follow. Regards, Dana. |
|
|
|
EricS,您能在上面所写的示例代码中显示,它应该看起来像使用命令SCKYDATAYADDR=SCKIMAGE和SCKYDATAYADDR&= ~SCKIMAGE?我试着用它
当做 以上来自于百度翻译 以下为原文 EricS , Could You show on the example code you wrote above, it should look like using the command SCK_Data_ADDR |= SCK_MASK and SCK_Data_ADDR &= ~SCK_MASK ?? I try to use it.. Regards |
|
|
|
忘记添加
在3271的用户指南中有一个节点配置示例 对于热敏电阻固件,您可以遵循。 问候,Dana。 以上来自于百度翻译 以下为原文 Forgot to add - In the user guide for 3271 there is a node configuration example for the thermistor firmware that you can follow. Regards, Dana. |
|
|
|
每次遇到一个表示SCK=1的行时,用SCKYDATAAdAdR=SkkMask替换它,当它是SCK=0时,您就改变了FrSCKYDATAADADR和= ~SCKY-掩码行。
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ chssWrue字节(无符号字符值) ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ //在感知器上写入一个字节并检查确认 { 无符号char i,误差=0; 对于(i=0x80;i & gt;0;I/= 2)/ /移位位形式化请求 {if(i,and value)DATAXDATAYADDR=DATA掩码;/ /用I掩蔽值,写入敏感器总线 否则DATAXDATAYADDR和= ~DATAAI掩模; (nopp);/ /观察设置时间 SKKY-DATAAdARDR=SCKIMAGE;/CLK为敏感总线 αnoph();αnoph();//脉冲约5μs; SCKYDATAYADDR和= ~SCKY面罩; (nopp);/ /观察保持时间 } DATAXDATAYADDR=DATA掩码;/ /释放数据线 (nopp);/ /观察设置时间 SKKYDATAYADDR=SCKIMAGE;//CLKα9用于ACK 错误=数据;//检查ACK(数据将被SHT11拉下来) SCKYDATAYADDR和= ~SCKY面罩; 返回错误;//错误=1在没有确认的情况下 } / /结束样本代码 这就是代码应该是什么样子的。你会说我重复了两次数据,但是这种方法是完全正确的。请看一个名为PSoCGPIOIt.h的文件,在库头文件中,它用输入的名称定义IO。 使用这种编码方式,您可以在不更改代码的情况下更改IO位置。 以上来自于百度翻译 以下为原文 Everytime you encounter a line stating SCK = 1, you replace it with SCK_Data_ADDR |= SCK_MASK and when it is SCK = 0, you change the line for SCK_Data_ADDR &= ~SCK_MASK //---------------------------------------------------------------------------------- char s_write_byte(unsigned char value) //---------------------------------------------------------------------------------- // writes a byte on the Sensibus and checks the acknowledge { unsigned char i,error=0; for (i=0x80;i>0;i/=2) //shift bit formasking { if (i & value) Data_Data_ADDR |= Data_MASK; //masking valuewith i , write to SENSI-BUS else Data_Data_ADDR &= ~Data_MASK; _nop_(); //observe setuptime SCK_Data_ADDR |= SCK_MASK; //clk for SENSI-BUS _nop_();_nop_();_nop_(); //pulswith approx. 5 us SCK_Data_ADDR &= ~SCK_MASK; _nop_(); //observe holdtime } Data_Data_ADDR |= Data_MASK; //release DATA-line _nop_(); //observe setuptime SCK_Data_ADDR |= SCK_MASK; //clk #9 for ack error=DATA; //check ack (DATA will be pulled down by SHT11) SCK_Data_ADDR &= ~SCK_MASK; return error; //error=1 in case of no acknowledge } // End of sample code This is the way the code should look like. You will say I repeated Data twice but it's perfectly correct this way. Have a look at the file named PSocGPIOINT.h under the library header file it defines the IO with the name you gave them. Using this way of coding, you can change the IO location without changing your code. |
|
|
|
最后,CDROM是用于节点配置的模板文件。
使用热敏电阻的示例固件。所以你可以在节点编辑器中打开它 看看这是如何做的第一个例子。 问候,Dana。 以上来自于百度翻译 以下为原文 Lastly on the CDROM is a template file for the node configuration for the example firmware using Thermistor. So you can open that in the node editor to see how that was done for the firware example. Regards, Dana. |
|
|
|
我只有GoopalPARAMS。h,我不知道pSoGPooIt.h。但是我如何定义SCKYDATAYADADR=SCKYMASE,SCKYDATAYADDR&= ~SCKYMASE,并且两个推荐数据在编译中没有错误?最重要的问题是:如何为这个推荐设置端口?例如,我将非常感激。
当做。 以上来自于百度翻译 以下为原文 I have only GlobalParams.h I dont see PSocGPIOINT.h. But how do I define SCK_Data_ADDR |= SCK_MASK , SCK_Data_ADDR &= ~SCK_MASK and two commend to DATA that there is no error in the compilation ?? The most important question is : How can I set ports for this commend ? I will be very grateful for example. Regards. |
|
|
|
你能帮我在我的代码中使用这个例子吗?(如果你可以的话)一些代码,因为我不理解这个应用笔记和例子。谢谢大家的帮助。
当做 以上来自于百度翻译 以下为原文 Can You help me to use this example in my code ? (some code if you Can) Because I dont understend this app note and examples. Thanks for all help. Regards |
|
|
|
好的,我加上了这个,但是我该换什么呢?虽然有很多问题,但我会尝试做一些事情,我会自我否定,但我的知识并不太大。谢谢大家的帮助。
当做。 以上来自于百度翻译 以下为原文 Ok i add and found this libery but what should I change ? Sory for a lot of question but I would try to do something and I have self-denial but my knowledge is not too great. Thanks for all help. Regards. |
|
|
|
所以我用这个代码:
包含所有用户模块的“pSOCAPI .h”//PSoC API定义包括:“PSoGPIPONT.H”//OBSLUGUI PORTOW-OXILICAL.L.M.H.G.//Keil LoablSug;定义的数据INT1;浮点F;}值;EnUM {HUMI};定义数据P1(5)/LINIAN DANCHECY定义SKP1(7)/LINIA ZEGAROWAα定义定义NoPo*()定义NACK 0α定义ACK 1α定义StasuSuxRigW0x06//000 0011 0π定义StasuSuxReGr0x07//000 0011 1,定义DealthHUM0x05//000 0010 0010定义定义重置。0x1e// 000 1111 0 char sWrad写字节(无符号char值){无符号char i,错误=0;(i=0x80;i & gt;0;i/= 2)/移位位请求{{if(i;and value)DATAYDATAYADDR=DATA掩码;/ /掩蔽值I,写入SeN-BUS数据包DATAYDATAYADDR和= ~DATAAL掩码;TukStDATAdAdAdDr=SCKIMAGE;//CLK为SeN-Boop-Nopopy(;);nopoph(;)//脉冲,具有大约5个SkpDATAdAdDADA&DRAMP;=~SCKyMask.;ACK错误=DATAXDATAYADDR;//检查ACK(数据将被SHT10拖拽)SCKYDATAYADADR和;= ~SCKYMASK;返回错误;//错误=1,在没有确认的情况下,CHAR SyRead字节(无符号CHACK){无符号char i,Var=0;DATAYDATAYADDR=1;//释放数据线为(i=0x80;i & gt;0;I/= 2)//用于掩蔽{SKKYDATAAdADDR=SCKIMAGE掩码的移位位;//CYK为敏感器总线IF(DATAXDATAAADDR)VAL=(Vali i);/ /读取位SCKYDATAAADADR和;= ~SCKYMASE;} DATAYDATAYADDR=!ACK;//在“ACK=1”的情况下,下拉数据线SCKYDATAAdAdR=SCKIMAGE;//CLKα9,ACK-Nopopy();γnopl();/ /脉冲约5个SCKYDATAADADR和;= ~SCKYMASE;DATAYDATAAADADR=DATA掩码;//释放数据线返回Val.;Ikjaliasja Stand数据=1 SCK=1μNopy();SkkyDATAYADDR=SCKIMAGE;;TAKEMAGE;SCKYDATAYADDR;SKKY-DATAAdAdD&Apdia&=~SCKYMase};空SnCalnAccess Read(空隙){无符号chi;DATAYDATAAdADDR=DATAYMAGE;SCKYDATAYADDR&AMP;= ~SCKYMASK;//Injjalasaja Stand(i=0;I & lt;9;i++)// 9 CykLoSck {SkkDATAdAdDr=SkkMask};SCKYDATAYADDR & =;αnoph();TART();//启动TraceReqStaseReg(未签名的char *p值,未签名的char px校验和){无符号char错误=0;SyTraseSistar();//传输开始错误=sxWrrEyLyByb(StasuSug ReGrr);/ /发送命令到传感器* pyValue= SyRead字节(ACK);/ /读取状态寄存器(8位)*PL检查UM=SyRead字节(NOACK);/ /读取校验和(8位)返回错误;//错误=1,在没有响应的情况下,传感器为char sxWraveStasuReg(无符号char *pl值){un-char错误=0;SyTraseSistar();//传输开始错误+= SyWrreEthyByg(StasuSug ReGuw);/ /发送命令到传感器错误+= SywRITEYBEY字节(*PyValuy);/状态寄存器返回错误的发送值;//GRT;=1,在没有响应的情况下,由传感器} char s测度(未签名的char *pl值,无符号char p*校验和,无符号char模式){无符号错误=0;未签名int i;s*TraseTest-();/ /发送开始开关(MO)D/{//发送命令到传感器外壳HUM:错误+= SyRead EythyByg(TraceHuMi);中断;默认值:中断;}(i=0;i&lt;65535;i++):(DATAXDATAAADADR==0)中断;和/或等待直到传感器完成测量(DATAXDATAAADADR)错误+= 1;和/或超时(2秒)达到*(Py值)=SyRead yBytE(ACK);/ /读取第一字节(MSB)*(pHy值+ 1)=SyRead字节(ACK);/ /读取第二字节(LSB)*PyCuthSUM=SyRead字节(NOACK);/ /读取校验和返回错误;}空主(空){值HoMIIVAL;无符号字符错误,校验和;未签名int i;SyChansReSETET();而(1){错误=0;Erro;R+=SY测度((无符号char)和;HuimiVal.i,and;校验和,HUMI);/ /测量湿度(如果错误)!=(0)SyCouthRealSeTo();//在错误的情况下:连接重置{ HuimiVal.F=(浮点)HoimialVal.I;/ /将整数转换为浮点}//-------等待大约0.8s以避免加热SHTXX --------------------------(i=0;i & lt;40000;i++);//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------} 我在示波器上看不到任何东西。错误在哪里?谢谢大家的帮助。 当做。 以上来自于百度翻译 以下为原文 So I use this code: #include #include "PSoCAPI.h" // PSoC API definitions for all User Modules #include "PSoCGPIOINT.h" // do obslugi portow #include #include typedef union // zdefiniowanie zmiennych { unsigned int i; float f; } value; enum {HUMI}; #define Data P1[5] // linia danych #define SCK P1[7] // linia zegarowa #define _nop_() #define noACK 0 #define ACK 1 #define STATUS_REG_W 0x06 //000 0011 0 #define STATUS_REG_R 0x07 //000 0011 1 #define MEASURE_HUMI 0x05 //000 0010 1 #define RESET 0x1e //000 1111 0 char s_write_byte(unsigned char value) { unsigned char i,error=0; for (i=0x80;i>0;i/=2) //shift bit formasking { if (i & value) Data_Data_ADDR |= Data_MASK; //masking valuewith i , write to SENSI-BUS else Data_Data_ADDR &= ~Data_MASK; _nop_(); //observe setuptime SCK_Data_ADDR |= SCK_MASK; //clk for SENSI-BUS _nop_();_nop_();_nop_(); //pulswith approx. 5 us SCK_Data_ADDR &= ~SCK_MASK; _nop_(); //observe holdtime } Data_Data_ADDR |= Data_MASK; //release DATA-line _nop_(); //observe setuptime SCK_Data_ADDR |= SCK_MASK; //clk #9 for ack error=Data_Data_ADDR; //check ack (DATA will be pulled down by SHT10) SCK_Data_ADDR &= ~SCK_MASK; return error; //error=1 in case of no acknowledge } char s_read_byte(unsigned char ack) { unsigned char i,val=0; Data_Data_ADDR=1; //release DATA-line for (i=0x80;i>0;i/=2) //shift bit for masking { SCK_Data_ADDR |= SCK_MASK; //clk for SENSI-BUS if (Data_Data_ADDR) val=(val | i); //read bit SCK_Data_ADDR &= ~SCK_MASK; } Data_Data_ADDR=!ack; //in case of "ack==1" pull down DATA-Line SCK_Data_ADDR |= SCK_MASK; //clk #9 for ack _nop_();_nop_();_nop_(); //pulswith approx. 5 us SCK_Data_ADDR &= ~SCK_MASK; Data_Data_ADDR |= Data_MASK; //release DATA-line return val; } void s_transstart(void) { Data_Data_ADDR |= Data_MASK; SCK_Data_ADDR &= ~SCK_MASK; //Inicjalizacja stanow Data=1 SCK=1 _nop_(); SCK_Data_ADDR |= SCK_MASK; _nop_(); Data_Data_ADDR &= ~Data_MASK; _nop_(); SCK_Data_ADDR &= ~SCK_MASK; _nop_();_nop_();_nop_(); SCK_Data_ADDR |= SCK_MASK; _nop_(); Data_Data_ADDR |= Data_MASK; _nop_(); SCK_Data_ADDR &= ~SCK_MASK; } void s_connectionreset(void) { unsigned char i; Data_Data_ADDR |= Data_MASK; SCK_Data_ADDR &= ~SCK_MASK; //Inicjalizacja stanow for(i=0;i<9;i++) //9 cyklow SCK { SCK_Data_ADDR |= SCK_MASK; SCK_Data_ADDR &= ~SCK_MASK; } s_transstart(); //start transmisji } char s_read_statusreg(unsigned char *p_value, unsigned char *p_checksum) { unsigned char 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) return error; //error=1 in case of no response form the sensor } char s_write_statusreg(unsigned char *p_value) { unsigned char error=0; s_transstart(); //transmission start error+=s_write_byte(STATUS_REG_W);//send command to sensor error+=s_write_byte(*p_value); //send value of status register return error; //error>=1 in case of no response form the sensor } char s_measure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode) { unsigned error=0; unsigned int i; s_transstart(); //transmission start switch(mode){ //send command to sensor case HUMI : error+=s_write_byte(MEASURE_HUMI); break; default : break; } for (i=0;i<65535;i++) if(Data_Data_ADDR==0) break; //wait until sensor has finished the measurement if(Data_Data_ADDR) error+=1; // or timeout (~2 sec.) is reached *(p_value) =s_read_byte(ACK); //read the first byte (MSB) *(p_value+1)=s_read_byte(ACK); //read the second byte (LSB) *p_checksum =s_read_byte(noACK); //read checksum return error; } void main(void) { value humi_val; unsigned char error,checksum; unsigned int i; s_connectionreset(); while(1) { error=0; error+=s_measure((unsigned char*) &humi_val.i,&checksum,HUMI); //measure humidity if(error!=0) s_connectionreset(); //in case of an error: connection reset else { humi_val.f=(float)humi_val.i; //converts integer to float } //----------wait approx. 0.8s to avoid heating up SHTxx------------------------------ for (i=0;i<40000;i++); //----------------------------------------------------------------------------------- } } and I didn't see anything on the oscilloscope. Where is the error ? Thanks for all help. Regards. |
|
|
|
库文件PSoCGPIOIt.h是编译时生成的配置文件。使用键盘上的F6键,它将生成这个文件和UM所需的所有文件。
因为每次编译时都会重新生成文件,所以没有任何东西可以更改到文件PSoCGPIONT.H。我给你这个文件是为了帮助你了解我所说的一切都来自哪里。 当做 以上来自于百度翻译 以下为原文 The library file PSocGPIOINT.h is a compile time generated configuration file. Using the F6 key on your keyboard it will generate this file and all the file needed by the UM. You don't have anything to change to the file PSoCGPIOINT.h, since it is regenerated everytime you compile. I gave you this file in reference to help you understand where all of what i'm talking is coming from. regards |
|
|
|
这将有助于张贴整个项目,而不是发布一堆代码。您的问题可能在代码中,但也可能在芯片配置中。
确保驱动模式在所需要的引脚上是正确的。 当做 以上来自于百度翻译 以下为原文 It would help to post the entire project rather than posting a bunch of code. Your problem may be in the code, but it may be in the chip configuration too. Make sure the drive mode is correct on the needed pin. Regards |
|
|
|
使用GPIO
HTTP://www. CyPress?COM/?RID=2900 问候,Dana。 以上来自于百度翻译 以下为原文 Using GPIO - http://www.cypress.com/?rID=2900 Regards, Dana. |
|
|
|
这是下载项目的链接:
HTTP://www37.ZIPySyr.COM/V/8932512/FIL.HTML 我将非常感谢有人来改善这个项目,并插入一个链接下载。 当做。 以上来自于百度翻译 以下为原文 This is link to download project : http://www37.zippyshare.com/v/8932512/file.html I will be very grateful for someone to improve this project and insert a link to download. Regards. |
|
|
|
好的,但是在代码开始时,我应该如何定义来使用这个推荐呢?如何将PORT1L5定义为SCL行和PORT1O7到SDA线?
以上来自于百度翻译 以下为原文 Ok but what should I "define" in the beginning of code to use this commend ? How Can I define Port1_5 to SCL line and Port1_7 to SDA line ? |
|
|
|
改变您的引脚从高Z模拟驱动模式,拉或开漏高。如果选择漏极高,则需要外部上拉。
将你的“x定义”(nopp()”改为“*定义”。 这应该有帮助。 以上来自于百度翻译 以下为原文 Change the drive mode of your pin from High-z Analog to Pull-up or open drain high. If you select Open drain high you will require an external pull-up. Change your "#define _nop_()" to "#define _nop_() asm ("nop")". That should help |
|
|
|
你能演示一下如何用宏来改变“yNOP*”()吗??
以上来自于百度翻译 以下为原文 Can You show explain How Can I change the _nop_(); with a macro ??. |
|
|
|
我必须使用一些卡特等?我下载这个文件夹并添加这个库。你怎么利用这个延误?
链接到LyBibe和评论:HTTP://www. PrutePoSo.COM/CalpDealMeal-Cy/32-Delay-Fuff.HTML 以上来自于百度翻译 以下为原文 I must use some couter or etc. ? I download this folder and add this libary. What do you thing about use this delay ? link to libery and comment : http://www.planetpsoc.com/programming-assembly-and-c/32-delay-functions.html |
|
|
|
您不必在示例代码中定义宏,以将P1Y5和P1Y7分配给所需的信号。文件PSoCGPIONT.H正在为您做这件事。唯一需要做的是给出一个名称和驱动模式的PIN要使用的引脚窗格。
可以用这种方式定义NOP宏。 定义了一个“nopp”(“nop'”) 它将以这种方式使用nop*(); 当做 以上来自于百度翻译 以下为原文 You don't have to define a macro as in the example code to assign P1_5 and P1_7 to the signals you want. The file PSoCGPIOINT.h is doing it for you. The only thing you need to do is give a name and the drive mode of the pin you want to use under the Pinout pane. A nop macro can be defined this way #define _nop_() asm ("nop") It will be used this way _nop_(); Regards |
|
|
|
这将起作用,因为这个库来自LCD用户模块。
以上来自于百度翻译 以下为原文 This will work since this library is from the LCD user module. |
|
|
|
我会尝试,但我有错误。这是正确的吗?
定义数据端口Po1 17 7定义SCK PORTY1L5 以上来自于百度翻译 以下为原文 I would try but I have got error. This is correct ? #define DATA Port_1_7 #define SCK Port_1_5 |
|
|
|
只有小组成员才能发言,加入小组>>
754个成员聚集在这个小组
加入小组2106 浏览 1 评论
1853 浏览 1 评论
3671 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1788 浏览 6 评论
1536 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
572浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
424浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
438浏览 2评论
386浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
916浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 06:56 , Processed in 1.531453 second(s), Total 115, Slave 99 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号