Hallo,
hab ein kleines Problem, Bin grad dabei eine SPI umzubauen, ich möchte
ein clock für die SPI komponenten generieren, der clock ist ja abhängig
vom chipselect, so hab ichs versucht, aber leider kommt nicht das
richtige dabei raus. Hoffe es kann mir einer weiterhelfen.Danke.
1 | TestData: process(Reset, Clk)
|
2 | begin
|
3 | if Reset = '0' then
|
4 | Tdata <= (others => '1');
|
5 | Tcount <= 23; --23
|
6 | Tcount_2 <= 23;
|
7 | Tcs <= '1';
|
8 | Tsck <= '1';
|
9 | elsif rising_edge(Clk) then
|
10 | if DataCountValid = '1' then
|
11 | Tdata <= x"000011";--AddrIn & DataIn; --
|
12 | Tcount <= 0;
|
13 | Tcount_2 <= 0;
|
14 | Tcount_1 <= 0;
|
15 | else
|
16 |
|
17 |
|
18 | Tdata <= Tdata(22 downto 0) & '1';
|
19 | --Update bit counter
|
20 | if Tcount < 23 then
|
21 | Tcount <= Tcount + 1;
|
22 | end if;
|
23 | -- Set chip select
|
24 | if Tcount = 0 then
|
25 | Tcs <= '0';
|
26 | elsif Tcount = 22 then+
|
27 | Tcs <= '1';
|
28 | end if;
|
29 | if Tcount_2 < 23 then
|
30 | Tcount_2 <= Tcount_2 + 1;
|
31 | end if;
|
32 | if Tcs = '0' then
|
33 | if Tcount_2 = 0 then
|
34 | Tsck <= '0';
|
35 | elsif Tcount_2 = 23 then
|
36 | Tsck <= '1';
|
37 | end if;
|
38 | else
|
39 | Tsck <= '1';
|
40 | end if;
|
41 |
|
42 | end if;
|