Quadcount modul is currently not present, instead constant vector is supplied. Loading of 32-bit value works and a small sample code is added.
--- /dev/null
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.STD_LOGIC_ARITH.ALL;
+use IEEE.STD_LOGIC_UNSIGNED.ALL;
+
+entity omsp_quadcount is
+ port (
+ mclk : in std_logic;
+ per_addr : in std_logic_vector (7 downto 0);
+ per_din : in std_logic_vector (15 downto 0); -- unused
+ per_en : in std_logic;
+ per_wen : in std_logic_vector (1 downto 0); -- unused
+ puc : in std_logic; -- unused
+ per_irq_acc : in std_logic; -- unused
+ per_irq : out std_logic; -- unused
+ per_dout : out std_logic_vector (15 downto 0);
+
+ qcount : in std_logic_vector (31 downto 0)
+ );
+end omsp_quadcount;
+
+--------------------------------------------------------------------------------
+
+architecture behavioral of omsp_quadcount is
+
+ -- When reading whole 32-bit qcount input, first QCNTL has to be loaded, because
+ -- this event causes QCNTH to latch appropriate value of qcount. This procedure
+ -- ensures that correct value is readed.
+ constant QCNTL : std_logic_vector (15 downto 0) := X"0150"; -- qcount lower word logic address
+ constant QCNTH : std_logic_vector (15 downto 0) := X"0152"; -- qcount higher word logic address
+
+ signal qcntl_sel : boolean;
+ signal qcnth_sel : boolean;
+
+ signal qcnth_latch : std_logic_vector (15 downto 0) := (others => '0');
+
+ signal qcount_prev : std_logic_vector (31 downto 0) := (others => '0');
+
+--------------------------------------------------------------------------------
+
+begin
+
+ qcntl_sel <= (per_addr = QCNTL(8 downto 1)) and (per_en = '1');
+ qcnth_sel <= (per_addr = QCNTH(8 downto 1)) and (per_en = '1');
+
+ per_dout <= qcount (15 downto 0) when qcntl_sel else
+ qcnth_latch when qcnth_sel else
+ (others => '0');
+
+
+ process (mclk)
+ begin
+ if (rising_edge(mclk) and qcntl_sel) then
+ qcnth_latch <= qcount (31 downto 16);
+ end if;
+ end process;
+
+ -- Generation of IRQ signal. (changes in lower 2 bits are suppresed)
+ process (mclk)
+ begin
+ if (rising_edge(mclk)) then
+ qcount_prev <= qcount;
+
+ if (qcntl_sel) then
+ per_irq <= '0';
+ elsif (qcount_prev (31 downto 2) /= qcount (31 downto 2)) then
+ per_irq <= '1';
+ end if;
+ end if;
+ end process;
+
+end behavioral;
+
verilog work openmsp430/periph/omsp_gpio.v
verilog work openmsp430/periph/omsp_timerA.v
+vhdl work omsp_quadcount.vhd
+
vhdl work coregen/ram_8x512.vhd
vhdl work coregen/rom_8x2k.vhd
);
end component;
+ component omsp_quadcount is
+ port (
+ mclk : in std_logic;
+ per_addr : in std_logic_vector (7 downto 0);
+ per_din : in std_logic_vector (15 downto 0); -- unused
+ per_en : in std_logic;
+ per_wen : in std_logic_vector (1 downto 0); -- unused
+ puc : in std_logic; -- unused
+ per_irq_acc : in std_logic; -- unused
+ per_irq : out std_logic; -- unused
+ per_dout : out std_logic_vector (15 downto 0);
+
+ qcount : in std_logic_vector (31 downto 0)
+ );
+ end component;
+
signal mclk : std_logic;
signal puc : std_logic;
signal gpio_per_dout : std_logic_vector (15 downto 0);
signal timerA_per_dout : std_logic_vector (15 downto 0);
+ signal omsp_quadcount_dout : std_logic_vector (15 downto 0);
signal irq_ta0 : std_logic;
signal irq_ta1 : std_logic;
taclk => '0'
);
+ omsp_quadcount_0 : omsp_quadcount port map (
+ mclk => mclk,
+ per_addr => per_addr,
+ per_din => (others => '0'),
+ per_en => per_en,
+ per_wen => "00",
+ puc => '0',
+ per_irq_acc => '0',
+ per_irq => open,
+ per_dout => omsp_quadcount_dout,
+
+ qcount => X"0001E240" -- 123456
+ );
+
--------------------------------------------------------------------------------
- per_dout <= gpio_per_dout or timerA_per_dout;
+ per_dout <= gpio_per_dout or timerA_per_dout or omsp_quadcount_dout;
irq <= (9 => irq_ta0,
8 => irq_ta1,
#include <iomacros.h>
+//QuadCounter registers
+#define QCNTL_ 0x0150
+sfrw(QCNTL,QCNTL_);
+#define QCNTH_ 0x0152
+sfrw(QCNTH,QCNTH_);
+
+
//PINS
//PORT1
#define TX BIT1
/*
see README.txt for details.
-chris <cliechti@gmx.net>
+original by: chris <cliechti@gmx.net>
+
+modified by: Vladimir Burian <buriavl2@fel.cvut.cz>
*/
#include "hardware.h"
#include <stdlib.h>
#include "swuart.h"
#include "fll.h"
+/**
+QuadCounter value
+*/
+inline uint32_t qcount() {
+ uint32_t result = 0;
+
+ result |= QCNTL;
+ result |= ((uint32_t)QCNTH << 16);
+
+ return result;
+}
+
/**
Delay function.
*/
printf("\r\n====== openMSP430 in action ======\r\n"); //say hello
printf("\r\nSimple Line Editor Ready\r\n"); //say hello
+ printf("\n[QCount = 0x%08lX]\n", qcount());
+
while (1) { //main loop, never ends...
printf("> "); //show prompt
reading = 1;