Forum Discussion
Altera_Forum
Honored Contributor
15 years agoHow to destuff can frame?
Hi, I am trying to destuff can frame without using can controller. All i know about a can frame that 1) the normal size of can frame is 108 bits. If i have a max number of stuffed bits wil...
Altera_Forum
Honored Contributor
15 years agoI did not check your vhdl code, but your assumption is wrong. The normal size of a can frame is not 108 bits. There is no normal frame size. The frame size depends on the data length and the can identifier (11 bit or 29 bit identifier) of the transmitted frame. The shortest message can be 47 bits (without any stuff bits, 11 bit identifier, 0 data bytes), the longest message is 129 bits (29 bit identifier, 8 data bytes) + stuffbits.
I think an easier way to detect a stuff bit should be something like that. process(clk, reset_n) begin if(reset_n = '0') then stuffbit <= '0'; elsif(clk'event and clk = '1') then -- is next bit a stuff bit ? if(message_in(4 downto 0) = "11111" or message_in(4 downto 0) = "00000") then stuffbit <= '1'; else stuffbit <= '0'; end if; end if; end process;