Guest
#2628803
Hallo everybody, I am working on my bachelor project right now, and I have Coolrunner-II CPLD board (with 256 macrocells) and digital humidity/temperature I2C sensor Sensirion SHT21. I have managed to display data on 16x2 character display and 7seg display, but for now, I have only random numbers generated from LFSR to display. So my task is to get sensor working, and I found few sample codes in VHDL, bud they are complicated (and need lot of macrocells). Now the CPLD chip is allready 72% occupied. I think that without random number generation it can be somewhere around 65%, which gives me like 90 free macrocells (maybe more if I manage to simplyfi somehow the display/sseg part). I need to create very simple I2C master, to communicate with sensor. I studied I2C specification, so I know how it works, but I am quite new to VHDL. I will be working with only one I2C slave with constant address, and basically I need to send start condition, address and W! bit, ack by sensor, and then send meassure command (8bits). Wait for meassurement and send S + address + R bit, ack by sensor and read 2 bytes of data. Sensor provides 2 modes (hold/no hold), in one SCL is blocked by sensor during meassurement, while in other master can communicate with other devices (no my case) and if meassurement not finished when sending add+read, sensor returnes NACK (and another add+read is needed to send). I am not going to calculate checksums, so after reading 2 bytes from sensor, master acknowlages with NACK + P. Probably I wold like to implement soft reset, which is just sending single command. I am not going to change user register (resolution of meassurement and stuff). Complete documentation is available here, especially chapter 5: http://www.sensirion.com/en/pdf/product_information/Datasheet-humidity-sensor-SHT21.pdf If you can help me with createing code for this (at least basics and proper state machine needed, and important thing I have to keep in mind) or you know of some ready to use code (but should be as simple as possible) I would be realy greatful. I know it is a long post, but I will appreciate any help. Thanks