Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] I need some advice about excessive skew because in my UART TX code.

Status
Not open for further replies.

Kepsz

Member level 1
Joined
Feb 7, 2012
Messages
32
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,521
This is my UART code:

Code:
library ieee ;
use ieee.std_logic_1164.all ;
use ieee.numeric_std.all;
     
entity txmit is
port (CLK_IN, START, CTS, RTS : in std_logic ;
		DATA_INPUT_0, DATA_INPUT_1 : in std_logic_vector(11 downto 0);
		UART_OUT  : out std_logic ) ;
end txmit ;

architecture v1 of txmit is  --For Digilent PmodUSBUart

signal TXD_TEMP_PUFFER: std_logic_vector (7 downto 0);
signal BAUD_CLK  :  std_logic;
signal state :  unsigned (5 downto 0);
type states is (Idle, Transmit, Loaddata); 
signal current_state : states;
signal next_state    : states;
     
begin
tx_states: process (BAUD_CLK, current_state, state)
	begin
		if (rising_edge(BAUD_CLK) ) then
			if (current_state = Transmit) then
				state <= state + "000001" ;
			else
				state <= "000000" ;
			end if;
		end if;
end process;

BAUD_RATE: process (CLK_IN)
		variable clk_div_counter : integer range 0 to 434;
	begin   
		if (rising_edge(CLK_IN)) then
			clk_div_counter := clk_div_counter + 1;
			if (clk_div_counter <= 217) then  --50MHz base CLK_IN / 9600baud = 5208,3 / 115200baud = 434,027  
				BAUD_CLK <= '1';
			else
				BAUD_CLK <= '0';
				if (clk_div_counter = 434) then
					clk_div_counter := 0;	--ISE 13.4 sucks with ranged integer, had to limit it manualy
				end if;
			end if;
		end if;
End Process;

NEXT_STATE_DECODE: process (CLK_IN, current_state, state, START)
	begin
		if (rising_edge(CLK_IN)) then
			next_state <= current_state;  --default is to stay in current state   
			case (current_state) is
				when Idle =>
					if (START = '1') then
						next_state <= Loaddata;
					end if;
				when Loaddata =>
					if (START = '0') then
						next_state <= Transmit;
					end if;
				when Transmit =>
					if (START = '0' and std_logic_vector(state) = "110001") then
						next_state <= Idle;
					end if;
				when others =>
					next_state <= Idle;
			end case;
		end if;
end process;
 
SYNC_PROC: process (CLK_IN)
	begin
		if (rising_edge(CLK_IN)) then
			current_state <= next_state;
		end if;
end process;

Transmit_process : process (BAUD_CLK, current_state, state, DATA_INPUT_0, DATA_INPUT_1, CTS, RTS)  -- data format: 1 start bit, 8 data bits, 2 stop bits, no parity bit, LSB first
	begin
		if (rising_edge(BAUD_CLK) and current_state = Transmit and RTS = '0' and CTS = '1' ) then  --RTS = '0' and CTS = '1' means the reciever is waiting for transmission
			if (std_logic_vector(state) = "000001") then  --start '0' bit, load input to puffer
				UART_OUT <= '0' ;
				TXD_TEMP_PUFFER <= DATA_INPUT_0(7 downto 0);
			elsif (std_logic_vector(state) >= "000010" and std_logic_vector(state) <= "001000") then  --shift out 8 bits data
				UART_OUT <= TXD_TEMP_PUFFER(0);
				TXD_TEMP_PUFFER <= "0" & TXD_TEMP_PUFFER(7 downto 1);
			elsif (std_logic_vector(state) = "001001") then
				UART_OUT <= TXD_TEMP_PUFFER(0) ;
			elsif (std_logic_vector(state) = "001010") then   -- number one stop '1' bit
				UART_OUT <= '1';
			elsif   (std_logic_vector(state) = "001011") then	-- number two stop '1' bit
				UART_OUT <= '1';
			-----------------------------------------------------------------------------------------------
			elsif (std_logic_vector(state) = "001100") then  --start '0' bit, load input to puffer
				UART_OUT <= '0';
				TXD_TEMP_PUFFER <= "0000" & DATA_INPUT_0(11 downto 8);
			elsif (std_logic_vector(state) >= "001101" and std_logic_vector(state) <= "010011") then  --shift out 8 bits data
				UART_OUT <= TXD_TEMP_PUFFER(0);
				TXD_TEMP_PUFFER <= "0" & TXD_TEMP_PUFFER(7 downto 1);
			elsif (std_logic_vector(state) = "010100") then
				UART_OUT <= TXD_TEMP_PUFFER(0);
			elsif (std_logic_vector(state) = "010101") then   -- number one stop '1' bit
				UART_OUT <= '1';
			elsif   (std_logic_vector(state) = "010110") then	-- number two stop '1' bit
				UART_OUT <= '1';
			-----------------------------------------------------------------------------------------------
			elsif (std_logic_vector(state) = "010111") then  --start '0' bit, load input to puffer
				UART_OUT <= '0';
				TXD_TEMP_PUFFER <= DATA_INPUT_1(7 downto 0);
			elsif (std_logic_vector(state) >= "011000" and std_logic_vector(state) <= "011110") then  --shift out 8 bits data
				UART_OUT <= TXD_TEMP_PUFFER(0);
				TXD_TEMP_PUFFER <= "0" & TXD_TEMP_PUFFER(7 downto 1);
			elsif (std_logic_vector(state) = "011111") then
				UART_OUT <= TXD_TEMP_PUFFER(0);
			elsif (std_logic_vector(state) = "100000") then   -- number one stop '1' bit
				UART_OUT <= '1';
			elsif   (std_logic_vector(state) = "100001") then	-- number two stop '1' bit
				UART_OUT <= '1';
			-----------------------------------------------------------------------------------------------
			elsif (std_logic_vector(state) = "100010") then  --start '0' bit, load input to puffer
				UART_OUT <= '0' ;
				TXD_TEMP_PUFFER <= "0000" & DATA_INPUT_1(11 downto 8);
			elsif (std_logic_vector(state) >= "100011" and std_logic_vector(state) <= "101001") then  --shift out 8 bits data
				UART_OUT <= TXD_TEMP_PUFFER(0);
				TXD_TEMP_PUFFER <= "0" & TXD_TEMP_PUFFER(7 downto 1);
			elsif (std_logic_vector(state) = "101010") then
				UART_OUT <= TXD_TEMP_PUFFER(0);
			elsif (std_logic_vector(state) = "101011") then   -- number one stop '1' bit
				UART_OUT <= '1';
			elsif   (std_logic_vector(state) = "101100") then	-- number two stop '1' bit
				UART_OUT <= '1';
			else
				UART_OUT <= '1';
			end if ;
		end if ;
end process ;
end ;

Xilinx ISE 13.4 constantly writes the excessive skew because message about the "BAUD_CLK". The code works, i mostly see the rigth values in laptop terminal. But if i try to start sending data bytes fast (putting high frequency to "start" input), the code makes mistakes with a big probability, showing constantly big numbers in the output.

In generaly, my imput is two 12 bit vector, and my output in the terminal is a decimal value 0 .. 4095. Input vectors are came from a latch, but this is not related to my problems.
 

You have problems becaus you have two different clock domains. The easiest way is to have only one clock domain.
Generate the baudrate as a pulse:

Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
BAUD_RATE: process (CLK_IN)
        variable clk_div_counter : integer range 0 to 434;
    begin   
        if (rising_edge(CLK_IN)) then
            BAUD_CLK <= '0';
            clk_div_counter := clk_div_counter + 1;
            if (clk_div_counter = 434) then  --50MHz base CLK_IN / 9600baud = 5208,3 / 115200baud = 434,027  
                BAUD_CLK <= '1';
                clk_div_counter := 0;
            end if;
        end if;
End Process;



The problem you have with ranged integer is not a fault in ISE 13.4
In VHDL, it is an error to go outside of the range. You must provide code to wrap the counter.

Use the baud rate clock like this:


Code VHDL - [expand]
1
2
3
4
tx_states: process (CLK_IN)
    begin
        if (BAUD_CLK = '1') then
            if (current_state = Transmit) then



I have not checked the rest of your code.
 
  • Like
Reactions: Kepsz

    Kepsz

    Points: 2
    Helpful Answer Positive Rating
Thank you, that was a great help! Warnings elliminated, and transmission works like before.

(About counter wraping, in ise 13.3, counters automaticaly wraped. When installed ise 13.4, i had to rewrite my older codes to include wraping the counter. Situation is same in the ise's simulator)


But the big number problem still exists. Measuring constant 3.3V give these results:

Code:
[root@chakra-pc ~]# od -An -d -N264 /dev/ttyUSB0 
  4088  4090  4093  4088  4088  4089  4092  4090
  4091  4091  4089  4091  4092  4089  4092  4088
  4091  4091  4091  4091  4092  4091  4092  4089
  4092  4088  4091  4091  4091  4089  4092  4091
  4091  4091  4092  4091  4092  4091  4091  4089
  4089  4091  4088  4091  4092  4089  4090  4092
  4092  4091  4093  4090  4092  4089  4088  4091
  4091  4088  4090  4088  4089  4091  4091  4091
  4090  4090  4090  4091  4091  4091  4088  4091
  4090  4088  4092  4089  4092  4090  4092  4089
  4092  4088  4089  4088  4092  4091  4092  4091
  4092  4088  4090  4091  4090  4090  4092  4089
  4091  4089  4088  4090
[root@chakra-pc ~]# od -An -d -N264 /dev/ttyUSB0 
 64512 63759 64015 64271 64527 64271 64271 64271
 64271 64271 64527 63759 64783 63759 64271 64271
 63503 64271 64783 63503 64271 63503 64783 64271
 64527 64271 64271 63503 64271 63759 64271 64015
 63759 64271 64527 64015 63503 64015 63759 64271
 63759 64527 63759 63503 63759 64271 64527 63503
 64527 64015 64271 64271 64527 63503 64271 64015
 64527 63503 64527 63759 64015 64015 64015 63759
 64271 64271 64015 64015 64527 64271 64783 64271
 64015 64527 64271 64271 64527 63503 64015 64527
 64271 64271 64527 63759 64015 64271 64527 64271
 64527 63759 64271 64271 64783 64271 64271 64527
 64527 64271 64015 64527
[root@chakra-pc ~]# od -An -d -N264 /dev/ttyUSB0 
  4090  4090  4090  4090  4093  4091  4091  4092
  4091  4089  4088  4088  4092  4091  4090  4090
  4091  4091  4091  4089  4091  4088  4092  4089
  4092  4090  4090  4091  4090  4091  4089  4091
  4093  4092  4090  4091  4092  4089  4092  4089
  4091  4088  4092  4091  4092  4091  4093  4091
  4092  4092  4091  4089  4091  4089  4092  4091
  4092  4092  4088  4091  4092  4088  4093  4090
  4092  4091  4088  4092  4092  4091  4092  4091
  4091  4091  4089  4088  4092  4089  4092  4091
  4088  4089  4092  4091  4088  4089  4089  4089
  4091  4089  4092  4091  4092  4091  4088  4091
  4090  4089  4092  4090
[root@chakra-pc ~]#

This is the actual code now:

Code:
library ieee ;
use ieee.std_logic_1164.all ;
use ieee.numeric_std.all;
     
entity txmit is
port (CLK_IN, START, CTS, RTS : in std_logic ;
		DATA_INPUT_0, DATA_INPUT_1 : in std_logic_vector(11 downto 0);
		UART_OUT  : out std_logic ) ;
end txmit ;

architecture v1 of txmit is  --For Digilent PmodUSBUart

signal TXD_TEMP_PUFFER: std_logic_vector (7 downto 0);
signal BAUD_CLK  :  std_logic;
signal state :  unsigned (5 downto 0);
type states is (Idle, Transmit, Loaddata); 
signal current_state : states;
signal next_state    : states;
     
begin
tx_states: process (CLK_IN, BAUD_CLK, current_state)
    begin
		if (rising_edge(CLK_IN)) then
			if (BAUD_CLK = '1') then
				if (current_state = Transmit) then
					state <= state + "000001";
				else
					state <= "000000" ;
				end if;
			end if;
		end if;
end process;

BAUD_RATE: process (CLK_IN)
        variable clk_div_counter : integer range 0 to 434;
    begin   
        if (rising_edge(CLK_IN)) then
            BAUD_CLK <= '0';
            clk_div_counter := clk_div_counter + 1;
            if (clk_div_counter = 434) then  --50MHz base CLK_IN / 9600baud = 5208,3 / 115200baud = 434,027  
                BAUD_CLK <= '1';
                clk_div_counter := 0;
            end if;
        end if;
End Process;

NEXT_STATE_DECODE: process (CLK_IN, current_state, state, START)
	begin
		if (rising_edge(CLK_IN)) then
			next_state <= current_state;  --default is to stay in current state   
			case (current_state) is
				when Idle =>
					if (START = '1') then
						next_state <= Loaddata;
					end if;
				when Loaddata =>
					if (START = '0') then
						next_state <= Transmit;
					end if;
				when Transmit =>
					if (START = '0' and std_logic_vector(state) = "110001") then
						next_state <= Idle;
					end if;
				when others =>
					next_state <= Idle;
			end case;
		end if;
end process;
 
SYNC_PROC: process (CLK_IN)
	begin
		if (rising_edge(CLK_IN)) then
			current_state <= next_state;
		end if;
end process;

Transmit_process : process (CLK_IN, BAUD_CLK, current_state, state, DATA_INPUT_0, DATA_INPUT_1, CTS, RTS)  -- data format: 1 start bit, 8 data bits, 2 stop bits, no parity bit, LSB first
	begin
	if (rising_edge(CLK_IN)) then
		if (BAUD_CLK = '1' and current_state = Transmit and RTS = '0' and CTS = '1' ) then  --CTS = '1' and RTS = '0' means the reciever is waiting for transmission
			if (std_logic_vector(state) = "000001") then  --start '0' bit, load input to puffer
				UART_OUT <= '0' ;
				TXD_TEMP_PUFFER <= DATA_INPUT_0(7 downto 0);
			elsif (std_logic_vector(state) >= "000010" and std_logic_vector(state) <= "001000") then  --shift out 8 bits data
				UART_OUT <= TXD_TEMP_PUFFER(0);
				TXD_TEMP_PUFFER <= "0" & TXD_TEMP_PUFFER(7 downto 1);
			elsif (std_logic_vector(state) = "001001") then
				UART_OUT <= TXD_TEMP_PUFFER(0) ;
			elsif (std_logic_vector(state) = "001010") then   -- number one stop '1' bit
				UART_OUT <= '1';
			elsif   (std_logic_vector(state) = "001011") then	-- number two stop '1' bit
				UART_OUT <= '1';
			-----------------------------------------------------------------------------------------------
			elsif (std_logic_vector(state) = "001100") then  --start '0' bit, load input to puffer
				UART_OUT <= '0';
				TXD_TEMP_PUFFER <= "0000" & DATA_INPUT_0(11 downto 8);
			elsif (std_logic_vector(state) >= "001101" and std_logic_vector(state) <= "010011") then  --shift out 8 bits data
				UART_OUT <= TXD_TEMP_PUFFER(0);
				TXD_TEMP_PUFFER <= "0" & TXD_TEMP_PUFFER(7 downto 1);
			elsif (std_logic_vector(state) = "010100") then
				UART_OUT <= TXD_TEMP_PUFFER(0);
			elsif (std_logic_vector(state) = "010101") then   -- number one stop '1' bit
				UART_OUT <= '1';
			elsif   (std_logic_vector(state) = "010110") then	-- number two stop '1' bit
				UART_OUT <= '1';
			-----------------------------------------------------------------------------------------------
			elsif (std_logic_vector(state) = "010111") then  --start '0' bit, load input to puffer
				UART_OUT <= '0';
				TXD_TEMP_PUFFER <= DATA_INPUT_1(7 downto 0);
			elsif (std_logic_vector(state) >= "011000" and std_logic_vector(state) <= "011110") then  --shift out 8 bits data
				UART_OUT <= TXD_TEMP_PUFFER(0);
				TXD_TEMP_PUFFER <= "0" & TXD_TEMP_PUFFER(7 downto 1);
			elsif (std_logic_vector(state) = "011111") then
				UART_OUT <= TXD_TEMP_PUFFER(0);
			elsif (std_logic_vector(state) = "100000") then   -- number one stop '1' bit
				UART_OUT <= '1';
			elsif   (std_logic_vector(state) = "100001") then	-- number two stop '1' bit
				UART_OUT <= '1';
			-----------------------------------------------------------------------------------------------
			elsif (std_logic_vector(state) = "100010") then  --start '0' bit, load input to puffer
				UART_OUT <= '0' ;
				TXD_TEMP_PUFFER <= "0000" & DATA_INPUT_1(11 downto 8);
			elsif (std_logic_vector(state) >= "100011" and std_logic_vector(state) <= "101001") then  --shift out 8 bits data
				UART_OUT <= TXD_TEMP_PUFFER(0);
				TXD_TEMP_PUFFER <= "0" & TXD_TEMP_PUFFER(7 downto 1);
			elsif (std_logic_vector(state) = "101010") then
				UART_OUT <= TXD_TEMP_PUFFER(0);
			elsif (std_logic_vector(state) = "101011") then   -- number one stop '1' bit
				UART_OUT <= '1';
			elsif   (std_logic_vector(state) = "101100") then	-- number two stop '1' bit
				UART_OUT <= '1';
			else
				UART_OUT <= '1';
			end if ;
		end if ;
	end if;
end process ;
end ;
 

I forgot the "rising_edge", but you discovered that:



Code VHDL - [expand]
1
2
3
4
5
tx_states: process (CLK_IN)
    begin
        if (rising_edge(CLK_IN)) then
            if (BAUD_CLK = '1') then
                if (current_state = Transmit) then



It is enough with CLK_IN in the sensitivity list since everything happens at the clock edge.

What is wrong with the big numbers?
What numbers do you expect?

As before, I have not checked most of your code.
 

The input is 12bit vector, so the maximum value is 4095.

I transmit the 12 bit in this 2*8bit form:
xxxxxxxx xxxx0000

If everything works normaly, the result must be smaller than 4096.
 

The big numbers are just a byte synchronization problem. You transmit and receive in 2-byte chunks, but you can not guarantee that the transmitter and receiver agree about where a chunk starts.
For a robust operation you should have a mechanism for the byte synchronization. You should not assume that the transmitter and receiver automatically will start synchronized.

One possibility is to send 6 bits of data in each byte, and use the remaining 2 bits to indicate first/second byte.
 

I'm still unable to get rid from the big number problem. I took out the garbage from the code, but the problem still randomly present.

Code:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
     
entity txmit is
port (CLK_IN, START, CTS : in std_logic;
		DATA_INPUT_0, DATA_INPUT_1 : in std_logic_vector(11 downto 0);
		UART_OUT, RTS  : out std_logic );
end txmit;

architecture v1 of txmit is  --For Digilent PmodUSBUart

signal TXD_TEMP_PUFFER	:	std_logic_vector(7 downto 0);
signal BAUD_CLK  			:	std_logic;
signal state				:	unsigned(5 downto 0);
type states is (Idle, Transmit); 
signal current_state		:	states;
signal next_state			:	states;
     
begin
tx_states: process (CLK_IN, current_state)
	begin
		if (rising_edge(CLK_IN)) then
			if (BAUD_CLK = '1') then
				if (current_state = Transmit) then
					state <= state + "000001";
					RTS <= '1';
				else
					state <= "000000";
					RTS <= '0';
				end if;
			end if;
		end if;
end process;

BAUD_RATE: process (CLK_IN)
		variable clk_div_counter : integer range 0 to 434;
	begin   
		if (rising_edge(CLK_IN)) then
			BAUD_CLK <= '0';
			clk_div_counter := clk_div_counter + 1;
			if (clk_div_counter = 434) then  --50MHz base CLK_IN / 9600baud = 5208,3 / 115200baud = 434,027  
				BAUD_CLK <= '1';
				clk_div_counter := 0;
			end if;
		end if;
End Process;

NEXT_STATE_DECODE: process (CLK_IN, current_state, state, START)
	begin
		if (rising_edge(CLK_IN)) then  
			case (current_state) is
				when Idle =>
					if (START = '1') then
						next_state <= Transmit;
					end if;
				when Transmit =>
					if (std_logic_vector(state) = "110000") then
						next_state <= Idle;
					end if;
				when others =>
			end case;
			current_state <= next_state;
		end if;
end process;

Transmit_process : process (CLK_IN, BAUD_CLK, current_state, state, DATA_INPUT_0, DATA_INPUT_1, CTS)  -- data format: 1 start bit, 8 data bits, 2 stop bits, no parity bit, LSB first
begin
	if (rising_edge(CLK_IN)) then
		if (BAUD_CLK = '1' and current_state = Transmit and CTS = '1') then  --CTS = '1' and RTS = '0' means the reciever is waiting for transmission
			if (std_logic_vector(state) = "000001") then  --start '0' bit, load input to puffer
				UART_OUT <= '0';
				TXD_TEMP_PUFFER <= DATA_INPUT_0(7 downto 0);
			elsif (std_logic_vector(state) >= "000010" and std_logic_vector(state) <= "001000") then  --shift out 8 bits data
				UART_OUT <= TXD_TEMP_PUFFER(0);
				TXD_TEMP_PUFFER <= "0" & TXD_TEMP_PUFFER(7 downto 1);
			elsif (std_logic_vector(state) = "001001") then
				UART_OUT <= TXD_TEMP_PUFFER(0);
			elsif (std_logic_vector(state) = "001010") then   -- number one stop '1' bit
				UART_OUT <= '1';
			elsif   (std_logic_vector(state) = "001011") then	-- number two stop '1' bit
				UART_OUT <= '1';
			-----------------------------------------------------------------------------------------------
			elsif (std_logic_vector(state) = "001100") then  --start '0' bit, load input to puffer
				UART_OUT <= '0';
				TXD_TEMP_PUFFER <= "0000" & DATA_INPUT_0(11 downto 8);
			elsif (std_logic_vector(state) >= "001101" and std_logic_vector(state) <= "010011") then  --shift out 8 bits data
				UART_OUT <= TXD_TEMP_PUFFER(0);
				TXD_TEMP_PUFFER <= "0" & TXD_TEMP_PUFFER(7 downto 1);
			elsif (std_logic_vector(state) = "010100") then
				UART_OUT <= TXD_TEMP_PUFFER(0);
			elsif (std_logic_vector(state) = "010101") then   -- number one stop '1' bit
				UART_OUT <= '1';
			elsif   (std_logic_vector(state) = "010110") then	-- number two stop '1' bit
				UART_OUT <= '1';
			-----------------------------------------------------------------------------------------------
			elsif (std_logic_vector(state) = "010111") then  --start '0' bit, load input to puffer
				UART_OUT <= '0';
				TXD_TEMP_PUFFER <= DATA_INPUT_1(7 downto 0);
			elsif (std_logic_vector(state) >= "011000" and std_logic_vector(state) <= "011110") then  --shift out 8 bits data
				UART_OUT <= TXD_TEMP_PUFFER(0);
				TXD_TEMP_PUFFER <= "0" & TXD_TEMP_PUFFER(7 downto 1);
			elsif (std_logic_vector(state) = "011111") then
				UART_OUT <= TXD_TEMP_PUFFER(0);
			elsif (std_logic_vector(state) = "100000") then   -- number one stop '1' bit
				UART_OUT <= '1';
			elsif   (std_logic_vector(state) = "100001") then	-- number two stop '1' bit
				UART_OUT <= '1';
			-----------------------------------------------------------------------------------------------
			elsif (std_logic_vector(state) = "100010") then  --start '0' bit, load input to puffer
				UART_OUT <= '0' ;
				TXD_TEMP_PUFFER <= "0000" & DATA_INPUT_1(11 downto 8);
			elsif (std_logic_vector(state) >= "100011" and std_logic_vector(state) <= "101001") then  --shift out 8 bits data
				UART_OUT <= TXD_TEMP_PUFFER(0);
				TXD_TEMP_PUFFER <= "0" & TXD_TEMP_PUFFER(7 downto 1);
			elsif (std_logic_vector(state) = "101010") then
				UART_OUT <= TXD_TEMP_PUFFER(0);
			elsif (std_logic_vector(state) = "101011") then   -- number one stop '1' bit
				UART_OUT <= '1';
			elsif   (std_logic_vector(state) = "101100") then	-- number two stop '1' bit
				UART_OUT <= '1';
			else
				UART_OUT <= '1';
			end if ;
		end if ;
	end if;
end process ;
end ;

I do something wrong in the TX process?
 

I'm still unable to get rid from the big number problem. I took out the garbage from the code, but the problem still randomly present.

Did you read my previous posting? When you start the "od" command, how do you know if the first received byte is the low byte or the high byte?

If you dump the data one byte at a time you will probably see what the problem is.
In the "od" command, replace "-d" with "-t x1" to get this command:

od -An -t x1 -N264 /dev/ttyUSB0
 

Hmm, byte sync will be needed, as u sad. Now i see what's going on. When every thing is ok, the format is like this:

(with -t x1)

0x xx 0x xx 0x xx ....., but when big numbers occure, the format is like this: xx 0x xx 0x xx 0x ...., so the value xx0x will be the displayed instead of 0xxx. Tomorrow i will try to solve this.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top