114369623 发表于 2010-10-20 11:23:20

FPGA控制触摸屏调试程序

entity TOUCH_TEST1_VHDL is
port(BUSY1: OUT STD_LOGIC;
   CSX : out std_logic;
          DIN : out std_logic;
          DOUT: IN std_logic;
          DCLK : out std_logic;
          clkin : in std_logic;
          DT : out std_logic_vector(11 downto 0)
          );
end TOUCH_TEST1_VHDL;

architecture Behavioral of TOUCH_TEST1_VHDL is
   signal fclk :std_logic:='0';
   signal count: integer range 0 to 33000000:=0;
        signal count1: integer range 0 to 33000000:=0;
   signal DCLKCnt : integer range 0 to 264:= 0;
        signal THR :   std_logic_vector(7 downto 0);       
        signal TSR :        std_logic_vector(7 downto 0);
        signal ShiftCnt1 : std_logic_vector(3 downto 0):="0000";
        signal RSR :        std_logic_vector(11 downto 0);       
        signal RSRII :        std_logic_vector(11 downto 0);       
        signal ShiftCnt2 : std_logic_vector(4 downto 0):="00000";                                    
        type State_Typ is (idle, start,shift, delay,ad,stop);
        signal TXM_State    : State_Typ;
   
begin
DIN1:process(fclk)
begin
        if rising_edge(fclk) then
       THR <="10010101"; --X+\AD12位\节电\无中断;
          case   TXM_State is
               whenidle =>
                                   CSX<= '1';
                                   BUSY1<='1';
                                   TXM_State <= start;
                               
               whenstart =>
                       if(count=20)then
                                   CSX<= '0';
                              BUSY1<= '0';
                                   TSR <= THR;               
                                   TXM_State <= shift;
                       else count<=count+1;       
          end if;
                       
          if(count=10)then                       
               CSX <= '1';
                                   BUSY1<='1';
                       end if;
                               
               whenshift =>
                         BUSY1<= '0';
                                   CSX<= '0';
                                   DIN <= TSR(0);
                                   TSR <= TSR(7 downto 1) & '0';
                                        TXM_State <= shift;
               ShiftCnt1 <= ShiftCnt1+1;                                       
                              if(ShiftCnt1=7) then
                                        TXM_State <= delay;
                                        else
                                             TXM_State <= shift;
                              end if;
                               
       when delay =>
                       if   (count=20) then       
                             BUSY1<='0';
                                       CSX<='0';
                                  TXM_State <= ad;
                       elsecount<=count+1;       
          end if;                               
          if   (count=10)then
                BUSY1<='1';
                                       CSX<='0';
                DT<="ZZZZZZZZZZZZ";
          end if;                                       
                       
       when   ad =>
                BUSY1<='0';
                                       CSX<='0';
          if   (RSR(0)=DOUT) then
                                  RSR <= DOUT & RSR(11 downto 1);
                                       ShiftCnt2 <= ShiftCnt2+1;
                               if (ShiftCnt2=11) then
                                          RSRII <= RSR;
                                          DT<= RSRII;
                                          TXM_State <= stop;
                                else
               TXM_State <= ad;                                          
                                end if;
          end if;                          
                                                               
       when   stop =>
                             CSX<= '1';
                                  BUSY1<='1';
                                  TXM_State <= idle;
                                  
               when others =>
                                  TXM_State <= idle;
                end case;
        end if;
end process DIN1;
---------------------------------------------------
p2: process(clkin)
begin
    if(clkin'event and clkin='1') then

              if (count1<11) then
                        count1<=count1+1;
          else
                        count1<=0;
                             fclk<=not fclk;
                                  DCLK<= fclk;
          end if;
   end if;
end process;       
end Behavioral;
上面是我做的一个触摸屏调试程序,发送8位控制字有些问题,请高手指点问题出在哪里,附件是触摸屏资料

114369623 发表于 2010-10-20 11:31:16

大家进来就讨论下啊

TCL 发表于 2010-10-21 21:02:35

zhichiyixia

weibode01 发表于 2010-11-9 10:56:09

触摸屏诶,好深
页: [1]
查看完整版本: FPGA控制触摸屏调试程序