Jump to content
  • 0

How could I use SPI in Basys3 board?


GreatGBL

Question

Hello I am a student and a part of my project need the Basys3 board to collect the data from ADC.

The Adc is Max11300 board, I know how to use it and this board use SPI way to communicate.

So I want to ask how could I build a way to communicate between Basys3 board and ADC(Max11300)  with SPI ?

I am very thanks for your help`.

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

8 minutes ago, hamster said:

Hi!

I am not familiar with your ADC, but this is using SPI to read a different ADC:

http://hamsterworks.co.nz/mediawiki/index.php/SPI_ADC

Hello, I am really thanks for your help, but it looks like the VHDL code for basys 2. However our lecture only tough the systemverlog for basys3, do you have this version? Thanks 

by the way, this ADC is not the problem, just using SPI communication.

Link to comment
Share on other sites

Hi GreatGBL,

@hamster's VHDL ADC code is a great option. Another potential option is Microblaze.  Here is an IP for the PmodAD1 that works with Microblaze and Zynq architectures. Unfortunately, the current IP isn't set up to use both channels that is available on the PmodAD1 but it is a spi based IP on the basys 3. Here is a link on creating a custom IP block.

cheers,

Jon

Link to comment
Share on other sites

A lot of the unanswered questions are around what you are trying to do.

Glancing through the datasheet (http://www.mouser.com/ds/2/256/MAX11300-335894.pdf), the ADC is fairly complex, and could require quite a bit of setup to get it configured and delivering sample data. There looks to be more than a handful of registers that need to be set. This makes me think that a micro-controller with a SPI peripheral or a soft CPU will be a good idea to use. 

The device also has a lot of channels, how many will you be using?

What do you want to do with the samples once you get the data?

 

 

Link to comment
Share on other sites

On 2017/1/24 at 10:09 PM, jpeyron said:

Hi GreatGBL,

@hamster's VHDL ADC code is a great option. Another potential option is Microblaze.  Here is an IP for the PmodAD1 that works with Microblaze and Zynq architectures. Unfortunately, the current IP isn't set up to use both channels that is available on the PmodAD1 but it is a spi based IP on the basys 3. Here is a link on creating a custom IP block.

cheers,

Jon

4

 

Hello, I want to ask, it is necessary to create an IP while I need to use SPI communication ? 

Link to comment
Share on other sites

 

On 2017/1/27 at 0:59 AM, hamster said:

A lot of the unanswered questions are around what you are trying to do.

Glancing through the datasheet (http://www.mouser.com/ds/2/256/MAX11300-335894.pdf), the ADC is fairly complex, and could require quite a bit of setup to get it configured and delivering sample data. There looks to be more than a handful of registers that need to be set. This makes me think that a micro-controller with a SPI peripheral or a soft CPU will be a good idea to use. 

The device also has a lot of channels, how many will you be using?

What do you want to do with the samples once you get the data?

 

 

2

Hello, for the previous work, I knew how to use the MAX11300 (20-channel-ADC), it can be modified to 8-channel-ADC, each channel connect to a microphone.

Then, the collected data transform to digital value, I need use Basys3 to collect the digital result and save them into a flash memory to SD card, After that, all the collected data send into Matlab to process.

 

My question is that how could I use Basys3 to connect the MAX11300(ADC) for collect the digital data? I only know the MAX11300 use SPI as bus. Thanks!

 

Kind regards,

GreatGBL

Link to comment
Share on other sites

@GreatGBL,

Hmm ... the flash on the Basys3 has a maximum data rate of 256 bytes per 3ms.  (page programming time, p48 of the spec found here)  That gives you a maximum programming speed on the order of 85kB/s.  I suppose that might handle 8 audio microphones, if each were sampling at 10kHz or slower.  You'd need to erase the sectors of the flash you intend to use first, though, before starting--'cause you wouldn't have time to do so while writing.

The SD Card is also a good idea, and with a proper/decent buffer, you should be able to transfer roughly 1MB/s to an SD card.  The difficulty with the SD card is that SD cards can be even more difficult to set up--although if you only need to set up one SD card, and you don't mind if the SD card is "properly" formatted or not, you should probably be okay there.  You'll need a PModSD or some such, since the Basys3 doesn't have an SD card connected to it.  I also know from my own experience from trying to program an SD card via an FPGA, that the SD card can sometimes suddenly "stop" accepting data, expecting you to be able to wait and buffer until it's ready again.

You might also consider a 4MBaud (400kB/s) UART data stream into the Basys-3 host computer.  You might find it to be an easier data transfer path than either of the other two you mentioned.

While many of these things require complicated setup arrangements, as @hamster pointed out, you might also be able to command the FPGA from a local PC and so keep the complexity from the FPGA itself.

Dan

Link to comment
Share on other sites

51 minutes ago, D@n said:

@GreatGBL,

Hmm ... the flash on the Basys3 has a maximum data rate of 256 bytes per 3ms.  (page programming time, p48 of the spec found here)  That gives you a maximum programming speed on the order of 85kB/s.  I suppose that might handle 8 audio microphones, if each were sampling at 10kHz or slower.  You'd need to erase the sectors of the flash you intend to use first, though, before starting--'cause you wouldn't have time to do so while writing.

The SD Card is also a good idea, and with a proper/decent buffer, you should be able to transfer roughly 1MB/s to an SD card.  The difficulty with the SD card is that SD cards can be even more difficult to set up--although if you only need to set up one SD card, and you don't mind if the SD card is "properly" formatted or not, you should probably be okay there.  You'll need a PModSD or some such, since the Basys3 doesn't have an SD card connected to it.  I also know from my own experience from trying to program an SD card via an FPGA, that the SD card can sometimes suddenly "stop" accepting data, expecting you to be able to wait and buffer until it's ready again.

You might also consider a 4MBaud (400kB/s) UART data stream into the Basys-3 host computer.  You might find it to be an easier data transfer path than either of the other two you mentioned.

While many of these things require complicated setup arrangements, as @hamster pointed out, you might also be able to command the FPGA from a local PC and so keep the complexity from the FPGA itself.

Dan

 

Thanks a lot for your answer, I am interesting on UART data, how could I set it on Basys3?  And then, because the ADC has SPI commuication as output, it is possible put the PmodSD module directly connect to the ADC?

Kind regards,

GreatGBL

Link to comment
Share on other sites

@GreatGBL,

Getting UART running on the Basys3 is the easier part of your task.  To do that, you can check out this project.  In the rtl/ directory, you'll find several examples of UART modules you can use for this purpose: a UART receiver, a UART transmitter, and even a module that connects both transmitter and receiver to a wishbone bus, should you wish to run it from such.  You'll also find in the bench/verilog directory a series of test programs for the UART that you can use as your top level program--just to test/prove if the UART works.  Finally, should you wish to do that test using Verilator, you'll find example code for running these test configurations using Verilator in the bench/cpp directory.  Part of what would make UART easy for your purpose is that you can design your own framing protocol to ride on top of it.

As for the SPI protocol on the SD card ... there's a lot of work/difference between a generic SPI protocol and one that will write to an SD card.  You'll want to take a hard look/read through the SD card spec if you are even contemplating this, with a special focus on chapter seven, describing how SD cards work across SPI.  If you'd like, you can take a look at the SD card over SPI project I built some time ago.  While I tend to think it's simple enough to use, you would still need to put a bus structure together to support it.  You ... aren't going to be able to just connect the two together and get them to work--at least, not like you might've connected your output to the UART and expected that to work.

Dan

Link to comment
Share on other sites

On 2017/1/30 at 10:42 AM, D@n said:

@GreatGBL,

Getting UART running on the Basys3 is the easier part of your task.  To do that, you can check out this project.  In the rtl/ directory, you'll find several examples of UART modules you can use for this purpose: a UART receiver, a UART transmitter, and even a module that connects both transmitter and receiver to a wishbone bus, should you wish to run it from such.  You'll also find in the bench/verilog directory a series of test programs for the UART that you can use as your top level program--just to test/prove if the UART works.  Finally, should you wish to do that test using Verilator, you'll find example code for running these test configurations using Verilator in the bench/cpp directory.  Part of what would make UART easy for your purpose is that you can design your own framing protocol to ride on top of it.

As for the SPI protocol on the SD card ... there's a lot of work/difference between a generic SPI protocol and one that will write to an SD card.  You'll want to take a hard look/read through the SD card spec if you are even contemplating this, with a special focus on chapter seven, describing how SD cards work across SPI.  If you'd like, you can take a look at the SD card over SPI project I built some time ago.  While I tend to think it's simple enough to use, you would still need to put a bus structure together to support it.  You ... aren't going to be able to just connect the two together and get them to work--at least, not like you might've connected your output to the UART and expected that to work.

Dan

 

Thanks! I finished it!

The main problem is that synchronize the clock in basys3 and clock in SPI.

Kind regards

GreatGBL

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...