Ignore:
Timestamp:
11/10/10 15:08:54 (14 years ago)
Author:
weitzel
Message:
CRC added for FTU RS485 communication
File:
1 edited

Legend:

Unmodified
Added
Removed
  • firmware/FTU/rs485/FTU_rs485_control.vhd

    r10037 r10050  
    8989
    9090  signal txcnt : integer range 0 to (RS485_BLOCK_WIDTH / 8) := 0;  -- count 28 1-byte frames
     91
     92  signal reset_crc_sig     : std_logic := '0';
     93  signal crc_enable_sig    : std_logic := '0';
     94  signal crc_input_sig     : std_logic_vector(RS485_BLOCK_WIDTH - 9 downto 0) := (others => '0');
     95  signal crc_sig           : std_logic_vector(CRC_POLYNOMIAL'length - 1 downto 0) := (others => '0');
     96  signal crc_sig_inv       : std_logic_vector(CRC_POLYNOMIAL'length - 1 downto 0) := (others => '0');
     97  signal crc_error_cnt_sig : integer range 0 to 255 := 0;
     98
     99  component ucrc_par
     100    generic(
     101      POLYNOMIAL : std_logic_vector;
     102      INIT_VALUE : std_logic_vector;
     103      DATA_WIDTH : integer range 2 to 256;
     104      SYNC_RESET : integer range 0 to 1
     105    );
     106    port(
     107      clk_i   : in  std_logic;
     108      rst_i   : in  std_logic;
     109      clken_i : in  std_logic;
     110      data_i  : in  std_logic_vector(DATA_WIDTH - 1 downto 0);
     111      match_o : out std_logic;
     112      crc_o   : out std_logic_vector(POLYNOMIAL'length - 1 downto 0)
     113    );
     114  end component;
    91115 
    92116  component FTU_rs485_receiver
     
    107131      block_valid            : IN  std_logic;
    108132      brd_add                : IN  std_logic_vector(5 downto 0);
     133      crc_error_cnt          : OUT integer range 0 to 255;
    109134      int_new_DACs           : OUT std_logic;
    110135      int_new_enables        : OUT std_logic;
     
    139164  end component;
    140165
    141   type FTU_rs485_control_StateType is (RECEIVE,
     166  type FTU_rs485_control_StateType is (INIT, RECEIVE,
    142167                                       READ_RATES_WAIT, READ_DAC_WAIT, READ_ENABLE_WAIT, READ_PRESCALING_WAIT,
    143                                        SET_DAC_WAIT, SET_ENABLE_WAIT, SET_PRESCALING_WAIT, PING_PONG_WAIT,
     168                                       READ_RATES_WAIT_2, READ_DAC_WAIT_2, READ_ENABLE_WAIT_2, READ_PRESCALING_WAIT_2,
     169                                       SET_DAC_WAIT, SET_ENABLE_WAIT, SET_PRESCALING_WAIT, PING_PONG_WAIT,                                       
     170                                       SET_DAC_WAIT_2, SET_ENABLE_WAIT_2, SET_PRESCALING_WAIT_2, PING_PONG_WAIT_2,
    144171                                       READ_RATES_TRANSMIT, READ_DAC_TRANSMIT, READ_ENABLE_TRANSMIT, READ_PRESCALING_TRANSMIT,
    145172                                       SET_DAC_TRANSMIT, SET_ENABLE_TRANSMIT, SET_PRESCALING_TRANSMIT, PING_PONG_TRANSMIT);
     
    147174 
    148175begin
     176
     177  crc_sig <= crc_sig_inv(0) & crc_sig_inv(1) & crc_sig_inv(2) & crc_sig_inv(3) & crc_sig_inv(4) & crc_sig_inv(5) & crc_sig_inv(6) & crc_sig_inv(7);
     178 
     179  Inst_ucrc_par : ucrc_par
     180    generic map(
     181      POLYNOMIAL => CRC_POLYNOMIAL,
     182      INIT_VALUE => CRC_INIT_VALUE,
     183      DATA_WIDTH => 216,
     184      SYNC_RESET => 1
     185    )
     186    port map(
     187      clk_i   => main_clk,
     188      rst_i   => reset_crc_sig,
     189      clken_i => crc_enable_sig,
     190      data_i  => crc_input_sig,
     191      match_o => open,
     192      crc_o   => crc_sig_inv
     193    );
    149194 
    150195  Inst_FTU_rs485_receiver : FTU_rs485_receiver
     
    164209      block_valid            => block_valid_sig,
    165210      brd_add                => brd_add,
     211      crc_error_cnt          => crc_error_cnt_sig,
    166212      int_new_DACs           => int_new_DACs_sig,
    167213      int_new_enables        => int_new_enables_sig,
     
    200246    if Rising_edge(main_clk) then
    201247      case FTU_rs485_control_State is
     248
     249        when INIT =>
     250          reset_crc_sig <= '1';
     251          FTU_rs485_control_State <= RECEIVE;
    202252       
    203         when RECEIVE =>  -- default state, receiver on, no transmission         
     253        when RECEIVE =>  -- default state, receiver on, no transmission
     254          reset_crc_sig <= '0';
     255          crc_enable_sig <= '0';
    204256          tx_start_sig <= '0';
    205257          if (int_new_DACs_sig = '1') then
     
    304356          if (DACs_ready = '1') then
    305357            new_DACs <= '0';
    306             FTU_rs485_control_State <= SET_DAC_TRANSMIT;
     358            crc_enable_sig <= '1';
     359            crc_input_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8)
     360                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     361                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     362                             & "00000000"
     363                             & conv_std_logic_vector(dac_array_rs485_in(7),16)(15 downto 8) & conv_std_logic_vector(dac_array_rs485_in(7),16)(7 downto 0)
     364                             & conv_std_logic_vector(dac_array_rs485_in(3),16)(15 downto 8) & conv_std_logic_vector(dac_array_rs485_in(3),16)(7 downto 0)
     365                             & conv_std_logic_vector(dac_array_rs485_in(2),16)(15 downto 8) & conv_std_logic_vector(dac_array_rs485_in(2),16)(7 downto 0)
     366                             & conv_std_logic_vector(dac_array_rs485_in(1),16)(15 downto 8) & conv_std_logic_vector(dac_array_rs485_in(1),16)(7 downto 0)
     367                             & conv_std_logic_vector(dac_array_rs485_in(0),16)(15 downto 8) & conv_std_logic_vector(dac_array_rs485_in(0),16)(7 downto 0) & "00000000"
     368                             & FIRMWARE_ID & "00" & brd_add & FTM_ADDRESS & RS485_START_DELIM;
     369            FTU_rs485_control_State <= SET_DAC_WAIT_2;
    307370          else
    308371            new_DACs <= '1';
     
    310373          end if;
    311374
     375        when SET_DAC_WAIT_2 =>
     376          crc_enable_sig <= '0';
     377          FTU_rs485_control_State <= SET_DAC_TRANSMIT;
     378         
    312379        when SET_ENABLE_WAIT =>  -- wait until FTU control says "done" and then answer to FTM
    313380          if (enables_ready = '1') then
    314381            new_enables <= '0';
    315             FTU_rs485_control_State <= SET_ENABLE_TRANSMIT;
     382            crc_enable_sig <= '1';
     383            crc_input_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8)
     384                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     385                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     386                             & "00000000" & "00000000" & "00000000"
     387                             & enable_array_rs485_in(3)(15 downto 8) & enable_array_rs485_in(3)(7 downto 0)
     388                             & enable_array_rs485_in(2)(15 downto 8) & enable_array_rs485_in(2)(7 downto 0)
     389                             & enable_array_rs485_in(1)(15 downto 8) & enable_array_rs485_in(1)(7 downto 0)
     390                             & enable_array_rs485_in(0)(15 downto 8) & enable_array_rs485_in(0)(7 downto 0) & "00000011"
     391                             & FIRMWARE_ID & "00" & brd_add & FTM_ADDRESS & RS485_START_DELIM;
     392            FTU_rs485_control_State <= SET_ENABLE_WAIT_2;
    316393          else
    317394            new_enables <= '1';
     
    319396          end if;
    320397
     398        when SET_ENABLE_WAIT_2 =>
     399          crc_enable_sig <= '0';
     400          FTU_rs485_control_State <= SET_ENABLE_TRANSMIT;
     401         
    321402        when SET_PRESCALING_WAIT =>  -- wait until FTU control says "done" and then answer to FTM
    322403          if (prescaling_ready = '1') then
    323404            new_prescaling <= '0';
    324             FTU_rs485_control_State <= SET_PRESCALING_TRANSMIT;
     405            crc_enable_sig <= '1';
     406            crc_input_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8)
     407                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     408                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     409                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     410                             & "00000000" & "00000000" & "00000000" & "00000000"
     411                             & overflow_array_rs485_in & prescaling_rs485_in & "00000110"
     412                             & FIRMWARE_ID & "00" & brd_add & FTM_ADDRESS & RS485_START_DELIM;
     413            FTU_rs485_control_State <= SET_PRESCALING_WAIT_2;
    325414          else
    326415            new_prescaling <= '1';
     
    328417          end if;
    329418
     419        when SET_PRESCALING_WAIT_2 =>
     420          crc_enable_sig <= '0';
     421          FTU_rs485_control_State <= SET_PRESCALING_TRANSMIT;
     422         
    330423        when READ_RATES_WAIT =>  -- wait until FTU control says "done" and then answer to FTM
    331424          if (rates_ready = '1') then
    332425            read_rates <= '0';
    333             FTU_rs485_control_State <= READ_RATES_TRANSMIT;
     426            crc_enable_sig <= '1';
     427            crc_input_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8)
     428                             & overflow_array_rs485_in
     429                             & conv_std_logic_vector(rate_array_rs485(4),32)(31 downto 24) & conv_std_logic_vector(rate_array_rs485(4),32)(23 downto 16)
     430                             & conv_std_logic_vector(rate_array_rs485(4),32)(15 downto 8) & conv_std_logic_vector(rate_array_rs485(4),32)(7 downto 0)
     431                             & conv_std_logic_vector(rate_array_rs485(3),32)(31 downto 24) & conv_std_logic_vector(rate_array_rs485(3),32)(23 downto 16)
     432                             & conv_std_logic_vector(rate_array_rs485(3),32)(15 downto 8) & conv_std_logic_vector(rate_array_rs485(3),32)(7 downto 0)
     433                             & conv_std_logic_vector(rate_array_rs485(2),32)(31 downto 24) & conv_std_logic_vector(rate_array_rs485(2),32)(23 downto 16)
     434                             & conv_std_logic_vector(rate_array_rs485(2),32)(15 downto 8) & conv_std_logic_vector(rate_array_rs485(2),32)(7 downto 0)
     435                             & conv_std_logic_vector(rate_array_rs485(1),32)(31 downto 24) & conv_std_logic_vector(rate_array_rs485(1),32)(23 downto 16)
     436                             & conv_std_logic_vector(rate_array_rs485(1),32)(15 downto 8) & conv_std_logic_vector(rate_array_rs485(1),32)(7 downto 0)
     437                             & conv_std_logic_vector(rate_array_rs485(0),32)(31 downto 24) & conv_std_logic_vector(rate_array_rs485(0),32)(23 downto 16)
     438                             & conv_std_logic_vector(rate_array_rs485(0),32)(15 downto 8) & conv_std_logic_vector(rate_array_rs485(0),32)(7 downto 0) & "00000010"
     439                             & FIRMWARE_ID & "00" & brd_add & FTM_ADDRESS & RS485_START_DELIM;
     440            FTU_rs485_control_State <= READ_RATES_WAIT_2;
    334441          else
    335442            read_rates <= '1';
     
    337444          end if;
    338445
     446        when READ_RATES_WAIT_2 =>
     447          crc_enable_sig <= '0';
     448          FTU_rs485_control_State <= READ_RATES_TRANSMIT;
     449         
    339450        when READ_DAC_WAIT =>  -- wait until FTU control says "done" and then answer to FTM
    340451          if (DACs_ready = '1') then
    341452            read_DACs <= '0';
    342             FTU_rs485_control_State <= READ_DAC_TRANSMIT;
     453            crc_enable_sig <= '1';
     454            crc_input_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8)
     455                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     456                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     457                             & "00000000"
     458                             & conv_std_logic_vector(dac_array_rs485_in(7),16)(15 downto 8) & conv_std_logic_vector(dac_array_rs485_in(7),16)(7 downto 0)
     459                             & conv_std_logic_vector(dac_array_rs485_in(3),16)(15 downto 8) & conv_std_logic_vector(dac_array_rs485_in(3),16)(7 downto 0)
     460                             & conv_std_logic_vector(dac_array_rs485_in(2),16)(15 downto 8) & conv_std_logic_vector(dac_array_rs485_in(2),16)(7 downto 0)
     461                             & conv_std_logic_vector(dac_array_rs485_in(1),16)(15 downto 8) & conv_std_logic_vector(dac_array_rs485_in(1),16)(7 downto 0)
     462                             & conv_std_logic_vector(dac_array_rs485_in(0),16)(15 downto 8) & conv_std_logic_vector(dac_array_rs485_in(0),16)(7 downto 0) & "00000001"
     463                             & FIRMWARE_ID & "00" & brd_add & FTM_ADDRESS & RS485_START_DELIM;
     464            FTU_rs485_control_State <= READ_DAC_WAIT_2;
    343465          else
    344466            read_DACs <= '1';
     
    346468          end if;
    347469
     470        when READ_DAC_WAIT_2 =>
     471          crc_enable_sig <= '0';
     472          FTU_rs485_control_State <= READ_DAC_TRANSMIT;
     473         
    348474        when READ_ENABLE_WAIT =>  -- wait until FTU control says "done" and then answer to FTM
    349475          if (enables_ready = '1') then
    350476            read_enables <= '0';
    351             FTU_rs485_control_State <= READ_ENABLE_TRANSMIT;
     477            crc_enable_sig <= '1';
     478            crc_input_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8)
     479                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     480                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     481                             & "00000000" & "00000000" & "00000000"
     482                             & enable_array_rs485_in(3)(15 downto 8) & enable_array_rs485_in(3)(7 downto 0)
     483                             & enable_array_rs485_in(2)(15 downto 8) & enable_array_rs485_in(2)(7 downto 0)
     484                             & enable_array_rs485_in(1)(15 downto 8) & enable_array_rs485_in(1)(7 downto 0)
     485                             & enable_array_rs485_in(0)(15 downto 8) & enable_array_rs485_in(0)(7 downto 0) & "00000100"
     486                             & FIRMWARE_ID & "00" & brd_add & FTM_ADDRESS & RS485_START_DELIM;
     487            FTU_rs485_control_State <= READ_ENABLE_WAIT_2;
    352488          else
    353489            read_enables <= '1';
     
    355491          end if;
    356492
     493        when READ_ENABLE_WAIT_2 =>
     494          crc_enable_sig <= '0';
     495          FTU_rs485_control_State <= READ_ENABLE_TRANSMIT;
     496         
    357497        when READ_PRESCALING_WAIT =>  -- wait until FTU control says "done" and then answer to FTM
    358498          if (prescaling_ready = '1') then
    359499            read_prescaling <= '0';
    360             FTU_rs485_control_State <= READ_PRESCALING_TRANSMIT;
     500            crc_enable_sig <= '1';
     501            crc_input_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8)
     502                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     503                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     504                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     505                             & "00000000" & "00000000" & "00000000" & "00000000"
     506                             & overflow_array_rs485_in & prescaling_rs485_in & "00000111"
     507                             & FIRMWARE_ID & "00" & brd_add & FTM_ADDRESS & RS485_START_DELIM;
     508            FTU_rs485_control_State <= READ_PRESCALING_WAIT_2;
    361509          else
    362510            read_prescaling <= '1';
     
    364512          end if;
    365513
     514        when READ_PRESCALING_WAIT_2 =>
     515          crc_enable_sig <= '0';
     516          FTU_rs485_control_State <= READ_PRESCALING_TRANSMIT;
     517         
    366518        when PING_PONG_WAIT =>  -- wait until FTU control says "done" and then answer to FTM
    367519          if (ping_pong_ready = '1') then
    368520            ping_pong <= '0';
    369             FTU_rs485_control_State <= PING_PONG_TRANSMIT;
     521            crc_enable_sig <= '1';
     522            crc_input_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8)
     523                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     524                             & "00000000" & "00000000" & "00000000" & "00000000" & "00000000"
     525                             & "00000000" & "00000000" & "00000000"
     526                             & dna(63 downto 0) & "00000101"
     527                             & FIRMWARE_ID & "00" & brd_add & FTM_ADDRESS & RS485_START_DELIM;
     528            FTU_rs485_control_State <= PING_PONG_WAIT_2;
    370529          else
    371530            ping_pong <= '1';
    372531            FTU_rs485_control_State <= PING_PONG_WAIT;
    373532          end if;
     533
     534        when PING_PONG_WAIT_2 =>
     535          crc_enable_sig <= '0';
     536          FTU_rs485_control_State <= PING_PONG_TRANSMIT;
    374537         
    375538        when SET_DAC_TRANSMIT =>
     
    457620            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 2) then        -- CRC error counter
    458621              txcnt <= txcnt + 1;
    459               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
    460               tx_start_sig <= '1';
    461               FTU_rs485_control_State <= READ_RATES_TRANSMIT;
     622              tx_data_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8);
     623              tx_start_sig <= '1';
     624              FTU_rs485_control_State <= SET_DAC_TRANSMIT;
    462625            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 1) then        -- check sum
    463626              txcnt <= txcnt + 1;
    464               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     627              tx_data_sig <= crc_sig;
    465628              tx_start_sig <= '1';
    466629              FTU_rs485_control_State <= SET_DAC_TRANSMIT;             
    467630            else                        -- transmission finished
    468631              txcnt <= 0;
     632              reset_crc_sig <= '1';
    469633              FTU_rs485_control_State <= RECEIVE;
    470634            end if;
     
    548712            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 2) then        -- CRC error counter
    549713              txcnt <= txcnt + 1;
    550               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     714              tx_data_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8);
    551715              tx_start_sig <= '1';
    552716              FTU_rs485_control_State <= SET_ENABLE_TRANSMIT;
    553717            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 1) then        -- check sum
    554718              txcnt <= txcnt + 1;
    555               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     719              tx_data_sig <= crc_sig;
    556720              tx_start_sig <= '1';
    557721              FTU_rs485_control_State <= SET_ENABLE_TRANSMIT;       
    558722            else                        -- transmission finished
    559723              txcnt <= 0;
     724              reset_crc_sig <= '1';
    560725              FTU_rs485_control_State <= RECEIVE;
    561726            end if;
     
    604769            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 2) then        -- CRC error counter
    605770              txcnt <= txcnt + 1;
    606               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     771              tx_data_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8);
    607772              tx_start_sig <= '1';
    608773              FTU_rs485_control_State <= SET_PRESCALING_TRANSMIT;
    609774            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 1) then        -- check sum
    610775              txcnt <= txcnt + 1;
    611               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     776              tx_data_sig <= crc_sig;
    612777              tx_start_sig <= '1';
    613778              FTU_rs485_control_State <= SET_PRESCALING_TRANSMIT;
    614779            else                        -- transmission finished
    615780              txcnt <= 0;
     781              reset_crc_sig <= '1';
    616782              FTU_rs485_control_State <= RECEIVE;
    617783            end if;
     
    755921            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 2) then        -- CRC error counter
    756922              txcnt <= txcnt + 1;
    757               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     923              tx_data_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8);
    758924              tx_start_sig <= '1';
    759925              FTU_rs485_control_State <= READ_RATES_TRANSMIT;
    760926            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 1) then        -- check sum
    761927              txcnt <= txcnt + 1;
    762               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     928              tx_data_sig <= crc_sig;
    763929              tx_start_sig <= '1';
    764930              FTU_rs485_control_State <= READ_RATES_TRANSMIT;
    765931            else                        -- transmission finished
    766932              txcnt <= 0;
     933              reset_crc_sig <= '1';
    767934              FTU_rs485_control_State <= RECEIVE;
    768935            end if; 
     
    8561023            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 2) then        -- CRC error counter
    8571024              txcnt <= txcnt + 1;
    858               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     1025              tx_data_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8);
    8591026              tx_start_sig <= '1';
    8601027              FTU_rs485_control_State <= READ_DAC_TRANSMIT;
    8611028            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 1) then        -- check sum
    8621029              txcnt <= txcnt + 1;
    863               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     1030              tx_data_sig <= crc_sig;
    8641031              tx_start_sig <= '1';
    8651032              FTU_rs485_control_State <= READ_DAC_TRANSMIT;             
    8661033            else                        -- transmission finished
    8671034              txcnt <= 0;
     1035              reset_crc_sig <= '1';
    8681036              FTU_rs485_control_State <= RECEIVE;
    8691037            end if; 
     
    9471115            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 2) then        -- CRC error counter
    9481116              txcnt <= txcnt + 1;
    949               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     1117              tx_data_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8);
    9501118              tx_start_sig <= '1';
    9511119              FTU_rs485_control_State <= READ_ENABLE_TRANSMIT;
    9521120            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 1) then        -- check sum
    9531121              txcnt <= txcnt + 1;
    954               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     1122              tx_data_sig <= crc_sig;
    9551123              tx_start_sig <= '1';
    9561124              FTU_rs485_control_State <= READ_ENABLE_TRANSMIT;   
    9571125            else                        -- transmission finished
    9581126              txcnt <= 0;
     1127              reset_crc_sig <= '1';
    9591128              FTU_rs485_control_State <= RECEIVE;
    9601129            end if; 
     
    10081177            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 2) then        -- CRC error counter
    10091178              txcnt <= txcnt + 1;
    1010               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     1179              tx_data_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8);
    10111180              tx_start_sig <= '1';
    10121181              FTU_rs485_control_State <= READ_PRESCALING_TRANSMIT;
    10131182            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 1) then        -- check sum
    10141183              txcnt <= txcnt + 1;
    1015               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     1184              tx_data_sig <= crc_sig;
    10161185              tx_start_sig <= '1';
    10171186              FTU_rs485_control_State <= READ_PRESCALING_TRANSMIT;
    10181187            else                        -- transmission finished
    10191188              txcnt <= 0;
     1189              reset_crc_sig <= '1';
    10201190              FTU_rs485_control_State <= RECEIVE;
    10211191            end if; 
     
    10261196
    10271197        when PING_PONG_TRANSMIT =>
     1198          crc_enable_sig <= '0';
    10281199          if tx_busy_sig = '0' then
    10291200            if txcnt = 0 then           -- start delimiter
     
    10991270            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 2) then        -- CRC error counter
    11001271              txcnt <= txcnt + 1;
    1101               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     1272              tx_data_sig <= conv_std_logic_vector(crc_error_cnt_sig, 8);
    11021273              tx_start_sig <= '1';
    11031274              FTU_rs485_control_State <= PING_PONG_TRANSMIT;
    11041275            elsif txcnt = ((RS485_BLOCK_WIDTH / 8) - 1) then        -- check sum
    11051276              txcnt <= txcnt + 1;
    1106               tx_data_sig <= "00000000";  -- NOT YET IMPLEMENTED!!!
     1277              tx_data_sig <= crc_sig;
    11071278              tx_start_sig <= '1';
    11081279              FTU_rs485_control_State <= PING_PONG_TRANSMIT;
    11091280            else                        -- transmission finished
    11101281              txcnt <= 0;
     1282              reset_crc_sig <= '1';
    11111283              FTU_rs485_control_State <= RECEIVE;
    11121284            end if; 
Note: See TracChangeset for help on using the changeset viewer.