Difference between revisions of "IOP16 UART"

From Land Boards Wiki
Jump to navigation Jump to search
Line 57: Line 57:
  
 
<pre>
 
<pre>
-- ____________________________________________________________________________________
+
<pre>
-- ACIA UART serial interface
+
-- 6850 style UART
-- Grant Searle's UART driver from Multicomp
+
UART: entity work.bufferedUART
-- Modified by Neal Crook from Grant Searle's code to use rising clk
+
  port map (
--   and to use baud rate enables rather than clocks
+
    clk     => i_CLOCK_50,
-- https://github.com/nealcrook/multicomp6809
+
    -- Strobes
w_UARTWr <= '1' when ((w_peripAddr(7 downto 1) = "0000010") and (w_peripWr = '1')) else '0';
+
    n_wr => not w_wrUart,
W_UARTRd <= '1' when ((w_peripAddr(7 downto 1) = "0000010") and (w_peripRd = '1')) else '0';
+
    n_rd    => not w_rdUart,
 +
    -- CPU
 +
    regSel  => w_periphAdr(0),
 +
    dataIn  => w_periphOut,
 +
    dataOut => w_UartDataOut,
 +
    -- Clock strobes
 +
    rxClkEn => serialEn,
 +
    txClkEn => serialEn,
 +
  -- Serial I/F
 +
    rxd    => rxd1,
 +
    txd    => txd1,
 +
    n_rts  => rts1,
 +
    n_cts  => cts1
 +
  );
 +
</pre>
  
acia: entity work.bufferedUART
 
  port map (
 
    clk    => i_clock,   
 
    n_WR    => not w_UARTWr,
 
    n_rd    => not W_UARTRd,
 
    regSel  => w_peripAddr(0),
 
    dataIn  => w_peripDataFromCPU,
 
    dataOut => w_UARTDataOut,
 
    rxClkEn => w_serialEn,
 
    txClkEn => w_serialEn,
 
    rxd    => i_uart_rx,
 
    txd    => o_uart_tx
 
);
 
 
</pre>
 
</pre>
  

Revision as of 10:45, 14 April 2022

UART and Baud Rate Generator

UART Programming Interface

  • Interface mimics ACIA software interface address/control/status contents
  • Two addresses, Control/status and data access

Status Register (Read)

  • Register Select = 0
  • Bits
d0 = RDRF = Receive Data Register Full (1 = data is ready to read)
d1 = TDRE = Transmit Data Register Empty (1 = transmit is ready to send out data)
d2 = DCD  = Data Carrier Detect (0 = carrier present - hardwired)
d3 = CTS  = Clear to Send (0 = Clear to Send - ready to accept data - hardwired)
d7 = IRQ  = Interrupt Request (1 = Interrupt present)

Control Register (Write)

  • Register Select = 0
  • Bits
d1,d0 = Control (11 = Master Reset)
d6,d5 = TC = Transmitter Control (RTS = Transmitter Interrupt Enable/Disable)
d7    = Interrupt Enable (1=enable interrupts)

Data Register (Read/Write)

  • Register Select = 1
    • Read = Read data from the data register (not implemented due to kbd removal)
    • Write = Write data to the data register

Baud Rate Generator for buffered UART

  • Assumes 50 MHz clock
  • Pass Baud Rate in BAUD_RATE generic as integer value (300, 9600, 115,200)
    • Legal values are 115200, 38400, 19200, 9600, 4800, 2400, 1200, 600, 300
  • Call with
BaudRateGen : entity work.BaudRate6850
GENERIC map (
	BAUD_RATE	=>  115200
)
PORT map (
	i_CLOCK_50	=> i_CLOCK_50,
	o_serialEn	=> serialEn
);

UART and Baud Rate Generator VHDL Entities

UART Entity

<pre>
-- 6850 style UART
UART: entity work.bufferedUART
  port map (
    clk     			=> i_CLOCK_50,
    -- Strobes
    n_wr				=> not w_wrUart,
    n_rd    			=> not w_rdUart,
    -- CPU 
    regSel  			=> w_periphAdr(0),
    dataIn  			=> w_periphOut,
    dataOut 			=> w_UartDataOut,
    -- Clock strobes
    rxClkEn 			=> serialEn,
    txClkEn 			=> serialEn,
   -- Serial I/F
    rxd     			=> rxd1,
    txd     			=> txd1,
    n_rts   			=> rts1,
    n_cts   			=> cts1
  );

Baud Rate Generator Entity

-- ____________________________________________________________________________________
-- Baud Rate Generator as an entity with passed baud rate
-- Legal BAUD_RATE values are 115200, 38400, 19200, 9600, 4800, 2400, 1200, 600, 300
BaudRateGen : entity work.BaudRate6850
  GENERIC map (
    BAUD_RATE	=>  115200
  )
  PORT map (
    i_CLOCK_50	=> i_clock,
    o_serialEn	=> w_serialEn
);

FPGA Resources (EP4CE15)

  • UART
  • Logic Cells: 154
    • Registers: 93
    • Memory Bits: 128
  • Baud Rate Generator
  • Logic Cells: 14
    • Registers: 13
    • Memory Bits: 0