Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Using a SPI module.

Altera_Forum
Honored Contributor II
2,111 Views

I have a SPI module.

Code:

But how do I actually use it?

In order to write to it I should load some data to SPI_Wr_Data and apply high signal to SPI_Wr_Start_Trig.

When the trigger applied the data shifted out on SPI_MasterOut pin.

SPI_Wr_Data <= "10010000";

triger <= '1';

SPI_Wr_Start_Trig<= triger ;

The question is - when I clear SPI_Wr_Start_Trig? i.e triger=0; SPI_Wr_Start_Trig <= triger.

Or let me paraphrase – how I write several bytes?

0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
1,247 Views

You should read the documentation provided with the core. 

If you dont have documentation, then find another core, or investigate how this one works. 

Where did you get this code from?
0 Kudos
Altera_Forum
Honored Contributor II
1,247 Views

Hi Tricky, 

Let me put it this way - do you have any working SPI module? If so - can you provide a practical example how to use it? 

I don't know the origin of SPI core I provided but I know for sure it's a working code cause it was used before. No I can't look at the previous use of the module - i don't have it.
0 Kudos
Altera_Forum
Honored Contributor II
1,247 Views

Suppose I have an SPI module. SPI_Wr_Data is a byte to send (8 bit). SPI_Wr_Start_Trig is a trigger to start byte transfer. How should I implement user logic to send several bytes?

0 Kudos
Altera_Forum
Honored Contributor II
1,247 Views

 

--- Quote Start ---  

Suppose I have an SPI module. SPI_Wr_Data is a byte to send (8 bit). SPI_Wr_Start_Trig is a trigger to start byte transfer. How should I implement user logic to send several bytes? 

--- Quote End ---  

 

 

If you have no documentation - I suggest finding a core that does have documentation and probably a testbench. 

From a brief look at this code, wr_start_trig starts sending a single byte. So for several bytes you just assert wr_start_trig at the start of every byte.
0 Kudos
Altera_Forum
Honored Contributor II
1,247 Views

I see. Thank you. I thought so. Is it right to do so? 

 

--first byte 

SPI_Wr_Data <= "00000001"; 

trigger <= '1'; 

SPI_Wr_Start_Trig <= trigger; 

--??? delay? 

trigger <= '0'; 

SPI_Wr_Start_Trig <= trigger; 

--second byte 

SPI_Wr_Data <= "00000011"; 

trigger <= '1'; 

SPI_Wr_Start_Trig <= trigger; 

trigger <= '0'; 

SPI_Wr_Start_Trig <= trigger; 

--and so on...
0 Kudos
Altera_Forum
Honored Contributor II
1,247 Views

Steps for success: 

1. Write your user logic 

2. Write a testbench containing your user logic and the SPI module 

3. test and debug 

4. ???? 

5. Profit!!
0 Kudos
Reply