Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
751 Views

VEEK MT - i2c_touch_config in VHDL

Hello, 

I'm trying to use the i2c_touch_config IP from the VEEK MT board (http://www.terasic.com.tw/cgi-bin/page/archive.pl?language=english&categoryno=139&no=670&partno=4) in VHDL. It is supposed to display the X positon of the first touchpoint with the red LEDs. The green LEDs should show if its a single or a multitouch. Somehow it just rises SIG_oREADY and doesnt respond to any touches. Did i assign the TOUCH_* pins wrong?  

 

 

library ieee; USE IEEE.STD_LOGIC_1164.all; entity Touchpaneltest is port ( CLOCK_50 : in std_logic; --//////////////////////// LED //////////////////////// LEDG : out std_logic_vector(8 downto 0); -- LED Green LEDR : out std_logic_vector(17 downto 0); -- LED Red --//////////////////////// TOUCH //////////////////////// TOUCH_INT_n : in std_logic; TOUCH_I2C_SCL : in std_logic; TOUCH_I2C_SDA : inout std_logic; ); end Touchpaneltest; architecture verhalten of Touchpaneltest is component i2c_touch_config is port( -- Host Side iCLK : in std_logic; -- Connect to 50 MHz Clock iRSTN : in std_logic; -- Connnct to system reset signal iTRIG : in std_logic; -- Connect to Interrupt Pin of Touch IC oREADY : out std_logic; -- Rising Trigger when following six output data is valid oREG_X1 : out std_logic_vector(9 downto 0); -- 10-bits X coordinate of first touch point oREG_Y1 : out std_logic_vector(8 downto 0); -- 9-bits Y coordinate of first touch point oREG_X2 : out std_logic_vector(9 downto 0); -- 10-bits X coordinate of second touch point oREG_Y2 : out std_logic_vector(8 downto 0); -- 9-bits Y coordinate of second touch point oREG_TOUCH_COUNT : out std_logic_vector(1 downto 0); -- 2-bits touch count. Valid value is 0, 1, 2 oREG_GESTURE : out std_logic_vector(7 downto 0); -- 8-bits gesture ID -- I2C Side I2C_SCLK : out std_logic; -- Connect to I2C Clock Pin of Touch IC I2C_SDAT : inout std_logic); -- Connect to I2C Data Pin of Touch IC end component; SIGNAL SIG_iTRIG, SIG_oREADY : std_logic; SIGNAL SIG_SCLK, SIG_SDAT : std_logic; SIGNAL SENSOR_X1, SENSOR_X2 : std_logic_vector(9 downto 0); SIGNAL SENSOR_Y1, SENSOR_Y2 : std_logic_vector(8 downto 0); SIGNAL SIG_TOUCH_COUNT : std_logic_vector(1 downto 0); SIGNAL SIG_GESTURE : std_logic_vector(7 downto 0); begin terasictouch: i2c_touch_config port map( iCLK => CLOCK_50, iRSTN => '1', iTRIG => TOUCH_INT_n, oREADY => SIG_oREADY, oREG_X1 => SENSOR_X1, oREG_Y1 => SENSOR_Y1, oREG_X2 => SENSOR_X2, oREG_Y2 => SENSOR_Y2, oREG_TOUCH_COUNT => SIG_TOUCH_COUNT, oREG_GESTURE => SIG_GESTURE, -- I2C Side I2C_SCLK => SIG_SCLK, I2C_SDAT => TOUCH_I2C_SDA); SIG_SCLK <= TOUCH_I2C_SCL; Led_test: PROCESS(CLOCK_50) IS begin LEDR <= "00000000"&SENSOR_X1(9 downto 0); if ( SIG_oREADY = '1') then LEDG(7) <= '1'; else LEDG(7) <= '0'; end if; if ( TOUCH_INT_n = '1') then LEDG(6) <= '1'; else LEDG(6) <= '0'; end if; case SIG_TOUCH_COUNT is when "00" => LEDG(0) <= '0'; LEDG(1) <= '0'; when "01" => LEDG(0) <= '1'; LEDG(1) <= '0'; when "10" => LEDG(0) <= '0'; LEDG(1) <= '1'; when "11" => LEDG(0) <= '1'; LEDG(1) <= '1'; when others => null; end case; END PROCESS Led_test; end verhalten;
0 Kudos
4 Replies
Altera_Forum
Honored Contributor I
35 Views

It might have something to do with the LED_test process not being synchronous. You put clock_50 in the senstivity list, but you didnt follow the template: 

 

process(clk) begin if rising_edge(clk) then --do sync stuff end if; end process;  

 

You just made an asynchronous process that would look synchronous in simulation - therefore simulation synthesis missmatch.
Altera_Forum
Honored Contributor I
35 Views

Thanks for your quick response. 

I added your suggestion, but it still doesn't work. I tested some things with the logic state analyzer. In the attached file you can see that it registers two touches, but none of the outputs change. TOUCH_COUNT is "11", which is an undefined state. Also TOUCH_I2C_SCL is always high, which is probably not right either.
Altera_Forum
Honored Contributor I
35 Views

did you testbench this?

Altera_Forum
Honored Contributor I
35 Views

No. I don't really know what i am supposed to test. 

 

EDIT: 

It works now. TOUCH_i2c_SCL is supposed to be an output ... 

 

library ieee; USE IEEE.STD_LOGIC_1164.all; entity Touchpaneltest is port ( CLOCK_50 : in std_logic; --//////////////////////// LED //////////////////////// LEDG : out std_logic_vector(8 downto 0); -- LED Green LEDR : out std_logic_vector(17 downto 0); -- LED Red --//////////////////////// TOUCH //////////////////////// TOUCH_INT_n : in std_logic; TOUCH_I2C_SCL : out std_logic; TOUCH_I2C_SDA : inout std_logic ); end Touchpaneltest; architecture verhalten of Touchpaneltest is component i2c_touch_config is port( -- Host Side iCLK : in std_logic; -- Connect to 50 MHz Clock iRSTN : in std_logic; -- Connnct to system reset signal iTRIG : in std_logic; -- Connect to Interrupt Pin of Touch IC oREADY : out std_logic; -- Rising Trigger when following six output data is valid oREG_X1 : out std_logic_vector(9 downto 0); -- 10-bits X coordinate of first touch point oREG_Y1 : out std_logic_vector(8 downto 0); -- 9-bits Y coordinate of first touch point oREG_X2 : out std_logic_vector(9 downto 0); -- 10-bits X coordinate of second touch point oREG_Y2 : out std_logic_vector(8 downto 0); -- 9-bits Y coordinate of second touch point oREG_TOUCH_COUNT : out std_logic_vector(1 downto 0); -- 2-bits touch count. Valid value is 0, 1, 2 oREG_GESTURE : out std_logic_vector(7 downto 0); -- 8-bits gesture ID -- I2C Side I2C_SCLK : out std_logic; -- Connect to I2C Clock Pin of Touch IC I2C_SDAT : inout std_logic); -- Connect to I2C Data Pin of Touch IC end component; SIGNAL SIG_oREADY : std_logic; SIGNAL SENSOR_X1, SENSOR_X2 : std_logic_vector(9 downto 0); SIGNAL SENSOR_Y1, SENSOR_Y2 : std_logic_vector(8 downto 0); SIGNAL SIG_TOUCH_COUNT : std_logic_vector(1 downto 0); SIGNAL SIG_GESTURE : std_logic_vector(7 downto 0); begin terasictouch: i2c_touch_config port map( iCLK => CLOCK_50, iRSTN => '1', iTRIG => TOUCH_INT_n, oREADY => SIG_oREADY, oREG_X1 => SENSOR_X1, oREG_Y1 => SENSOR_Y1, oREG_X2 => SENSOR_X2, oREG_Y2 => SENSOR_Y2, oREG_TOUCH_COUNT => SIG_TOUCH_COUNT, oREG_GESTURE => SIG_GESTURE, -- I2C Side I2C_SCLK => TOUCH_I2C_SCL, I2C_SDAT => TOUCH_I2C_SDA); Led_test: PROCESS(TOUCH_INT_n) IS begin if rising_edge(TOUCH_INT_n) then LEDR <= "00000000"&SENSOR_X1(9 downto 0); if ( SIG_oREADY = '1') then LEDG(7) <= '1'; else LEDG(7) <= '0'; end if; case SIG_TOUCH_COUNT is when "00" => LEDG(0) <= '0'; LEDG(1) <= '0'; when "01" => LEDG(0) <= '1'; LEDG(1) <= '0'; when "10" => LEDG(0) <= '0'; LEDG(1) <= '1'; when "11" => LEDG(0) <= '1'; LEDG(1) <= '1'; when others => null; end case; end if; END PROCESS Led_test; end verhalten;
Reply