VHDL I2c burst read

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Dear All, please help with VHDL, i connected MPU6050 to my FPGA board.

I used  www.eewiki.com tutorial, can anybody exlpain me how to read burst data 16 bits from 2 registers  or  6 regsiters ? by only one operation ?

I use https://eewiki.net/pages/viewpage.action?pageId11%042934#SPItoI2CBridge (VHDL)-CodeDownload but reads only 1 byte .

any suggestion would be  appreciated/

Re: VHDL I2c burst read
On 1/5/2017 6:36 AM, snipped-for-privacy@gmail.com wrote:
Quoted text here. Click to load it

The eewiki page is about connecting an SPI master to an I2C slave  
through an FPGA.  Is that what you are doing?

The intro says the bridge will read 8 bit I2C registers.  It doesn't say  
anything about reading multiple registers in one SPI operation.   In  
fact, the SPI Mode section says the SPI interface must receive a 33 bit  
command to transfer a single 8 bit byte from the I2C slave to the SPI  
master.

I think if you want to do large transfers in one operation you will need  
to substantially change the SPI interface in the FPGA and possibly the  
rest of the design as well.

--  

Rick C

Re: VHDL I2c burst read
On Thursday, January 5, 2017 at 6:33:36 PM UTC+6, rickman wrote:
Quoted text here. Click to load it

Yes it is, i try to change i2c_to_spi conversion to i2c_to_PWM for servo, so I need 16 bit word from 2 register.

Re: VHDL I2c burst read
On Thursday, January 5, 2017 at 6:33:36 PM UTC+6, rickman wrote:
Quoted text here. Click to load it

I made register map file where is just puts device address, register address and value to make write or read operation and it write some value to initial device and reads results, but only 8 bits .
I think somewhere in I2C master or user logic file need to make edition. But my knowledge of VHDL is limited and cannot develop it more ))).  

Re: VHDL I2c burst read
On 1/5/2017 8:25 AM, snipped-for-privacy@gmail.com wrote:
Quoted text here. Click to load it

VHDL isn't the issue until you understand how to use the I2C bus.  Your  
other post seemed to indicate you are using an I2C master to control a  
servo with a PWM signal.  Is that correct?  I am no expert on I2C, but I  
believe it is not hard to send two bytes in one command.  You need to  
study the I2C bus spec.

If the entire I2C to PWM design is in your FPGA it should not be hard to  
design it to not glitch as the two 8 bit registers are updated  
separately.  So there are two ways to do this.

--  

Rick C

Re: VHDL I2c burst read

Quoted text here. Click to load it
 data 16 bits from 2 registers  or  6 regsiters ? by only one operation ?
Quoted text here. Click to load it
Bridge(VHDL)-CodeDownload but reads only 1 byte .
Quoted text here. Click to load it

I learned a lot of I2C from the I2C reference design for picoblaze embedded
 microcontroller in Xilinx. Picoblaze has a complete tool chain from assemb
ler to VHDL, and the code for the mcu can be downloaded to chip with JTAG t
o shorten development cycle.

Re: VHDL I2c burst read
I modified user logic from eewiki.com if someone need please use code below :

      WHEN read_data =>   ------------------------------------------------      
  
          message0 (15 downto 0)    <= "0000000000000000";
              
             i2c_busy_prev <= i2c_busy;                      
          IF (i2c_busy_prev = '0' AND i2c_busy = '1') THEN
              i2c_busy_cnt := i2c_busy_cnt + 1;                  
          END IF;
          CASE i2c_busy_cnt IS          
            WHEN 0 =>                                                
              i2c_ena     <= '1';                
              i2c_addr    <= data_in(6 downto 0);        
              i2c_rw      <= '0';                                      
              i2c_data_wr <= data_in(14 downto 7);      
            WHEN 1 =>
              i2c_ena     <= '1';                
              i2c_rw      <= data_in(15);                              
              i2c_data_wr <= data_in(23 downto 16);                                                    
            WHEN 2 =>                                                  
              i2c_ena     <= '1';              
              IF (i2c_busy = '0') THEN  
       message(15 downto 8) <= i2c_data_rd;                                                                            
              END IF;
            WHEN 3 =>                                                  
              i2c_ena     <= '0';              
              IF (i2c_busy = '0') THEN  
              message(7 downto 0) <= i2c_data_rd;                        
                  message(16)          <= i2c_ack_err;
              i2c_busy_cnt        := 0;                                
              state               <= combine;                        
              END IF;
            WHEN OTHERS => NULL;

Site Timeline