TCS34725 Basys3 VHDL  - Page 1
Forum section: electronics / general

author: kmesne
author_rank: Newbie
timestamp: March 26, 2019, 02:16:29 pm
content: Hi I am trying to use TCS34725 to identify Green and Red Colors, it has I2C interface and i could not find any I2C interface about this and i am not capable to write a protocol code what should I do I am stucked.I just need when it sees green it turns one led and when it sees red it turns another led.

author: rstofer
author_rank: Super Contributor
timestamp: March 26, 2019, 04:10:04 pm
content: If you don't know how to create a state machine to implement I2C master, you are in trouble. You could try some of the I2C cores at OpenCores.org but understanding somebody else's code is often more difficult than writing your own. And you still have to interface it to your main project.Since you're trying to do a very trivial application in an advanced device, I have to think this is homework. Nobody in their right mind would code up an I2C controller for a project that could be more easily done on a uC.OK, now that that's out of the way, you need to understand the I2C protocol and build up a state machine that will send the proper signals with appropriate timing. The datasheet gives you all the necessary information concerning transactions. NXP has a document for the I2C StandardAt the bottom level, you need to be able to control SCL and send a byte plus handle the Ack bit. Then you need to move up a level and implement the 3 different transactions shown on page 12 of the datasheet. Look at the very long time delays required as shown on pages 10 & 11.The suggestion on the Xilinx site to use a CPU core makes a lot of sense. This could allow you to bit-bang the protocol and this is going to be a LOT easier than creating an I2C core. But it still requires a CPU core and Xilinx provides that.This is going to be an enormous amount of work for a project that could be done in a few minutes on an Arduino. Maybe put an Arduino between the sensor and the FPGA. Let the Arduino deal with I2C and the sensor while using SPI to communicate between the Arduino and the FPGA. The SPI transaction could contain only the required information. Better yet, use a serial protocol over the UART.Or, change sensors and use the breakout board from Adafruit:https://www.adafruit.com/product/3779This board supports UART and that's a lot easier to implement in an FPGA than I2C.There is no way in the world I would want to get involved with I2C in an FPGA. Maybe if I used a CPU core and bit-banged it... I would not want to code a state machine.

author: colorado.rob
author_rank: Frequent Contributor
timestamp: March 26, 2019, 05:34:38 pm
content: There's money to be made, here, folks!https://www.reddit.com/r/FPGA/comments/b5qihx/tcs34725_basys3_vhdl/ejfe078?utm_source=share&utm_medium=web2x

author: rstofer
author_rank: Super Contributor
timestamp: March 27, 2019, 08:34:20 pm
content: Quote from: colorado.rob on March 26, 2019, 05:34:38 pmCool! I'm retired with plenty of time but the thing is, I don't get out of bed for less than $100/hour. Fortunately, I have priced myself out of the market so I have time for my projects. Nobody in their right mind would pay me that kind of money.Of all the things I wouldn't want to code, that I2C controller is at the top of the list. If I had to, I would use a CPU core and bit-bang the transactions. I2C is HARD! It's tough to get working even when all of the devices have internal controllers.There are other sensor breakout boards with UARTs. That is a LOT easier since the board accepts AT commands. I would still use a CPU core to manage the AT transactions.Pick up an atMega328 FPGA core. Go to OpenCores.org->Projects->Processors and search for atMega. There is one core that emulates either of atTiny, atMega or atXMega. Follow the yellow brick road. Do all the software development on an Arduino and port the code to the FPGA. Don't use any library functions and deal with the UART in code as a peripheral. Add a UART peripheral to the FPGA project. There are several at OpenCores.There is no way in the world I would want to write an I2C core.

author: NorthGuy
author_rank: Super Contributor
timestamp: March 27, 2019, 09:05:06 pm
content: Quote from: rstofer on March 27, 2019, 08:34:20 pmIt's not that bad if you don't call it a core. Not few months ago, I had to read DDR3 SPD (which is a little I2C EEPROM chip). It took me about an hour for the VHDL part.

author: SiliconWizard
author_rank: Super Contributor
timestamp: March 29, 2019, 02:15:12 pm
content: Was also posted on comp.arch.fpga.

author: Bassman59
author_rank: Super Contributor
timestamp: March 29, 2019, 09:57:44 pm
content: Quote from: SiliconWizard on March 29, 2019, 02:15:12 pmThat still exists?

author: SiliconWizard
author_rank: Super Contributor
timestamp: March 30, 2019, 12:13:42 am
content: Quote from: Bassman59 on March 29, 2019, 09:57:44 pmYes! Although there is little activity on those newsgroups now, they are not completely dead yet. I have a few subscriptions in Thunderbird that I have not resolved to delete, and I have a look occasionally.