Jump to content
  • 0

Support with the Pmod SD and Pmod AMP2


Jonathan.O

Question

We are working with the Digilent Basys 3 FPGA's and are tasked with a project based around retro game design.

For the game we are required to include music/sounds and for our implementation we required a bit more storage than the Basys 3 had to offer. To solve this problem, we searched for possible storage expansion modules and quickly found out that the Basys 3 supports a vast array of expansion modules.

 

To facilitate the sound production we chose the pmod AMP2 module and for the storage expansion we chose the pmod SD module.

We have successfully tested the example code that was provided within the IP library catalogue and got to testing. After some performance/feature testing we soon realised that there were some challenges with these modules based on our requirements. The modules are controlled through Microblaze, as the examples we found were written for the Microblaze soft core CPU.

 

The challenges are:

The latency/bandwidth of the SD module is a bit too high for our goals. We have tried to time the reading of different sized packets and concluded that the latency (tens of milliseconds with 2 kB read streams) that we are seeing might be too high and the bandwidth too low to get a sufficient amount of data through to stream high quality music and load in parts of the map from the SD card. Are there ways to increase the latency/bandwidth? Or is there VHDL code available that can handle reading data from the SD module at higher speeds (i.e. bypass Microblaze)? We need to be able to read samples (16 bit per sample at 44100 samples/s - 88.2 kB/s) from a text file to feed into the AMP2 module for music synthesis and also read bytes (18 kB per second) from another text file to generate a tile map for the game. Because the Basys 3 does not have a large amount of RAM available, we need to buffer a lot of information in relatively small buffers, which means that we require low latencies when it comes to reading data.

The pmod AMP2 has a class D amplifier that can output as much as 2.5 W of power. We hope to connect an aux cable to the 3.5 mm port and connect it to a portable speaker amplifier input (JBL bluetooth speaker aux port that is usually connected to a phone, for instance.). Is this possible or will the high current damage the amplifier inside the bluetooth speaker? And if the high current will damage the board, is it possible to reduce the volume (power) through software or does it then require a hardware modification?

We appreciate all the help!

 

Jonathan

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

Hello @Jonathan.O,

SD cards usually only guarantee write bandwidth through class specifications. Usually we can extrapolate read performance too. However, all the performance levels are specified for SD native interface, not SPI. Since you mentioned library code, I suspect you are using the SPI-based IP from here: https://github.com/Digilent/vivado-library/tree/master/ip/Pmods/PmodSD_v1_0.

Try an SD controller IP from OpenCores, see if it works better.

Link to comment
Share on other sites

Hi Jonathan,

PmodAmp2 is a class D audio amplifier. Supplied with 3.3V (in conjunction with Basys 3), it generates an output voltage up to 6.6Vpp. The output signal will consist in only 3 levels: -3.3V, 0V, +3.3V. The load circuitry should filter the pulse modulated signal to an audio analog signal.

The high input impedance of the speaker amplifier will not allow a high current. The voltage amplitude     can eventually damage the speaker amplifier. Please check if this withstands a voltage of +/-3.3V (6.6Vpp).

Reducing the “volume” of the digital signal would not help: the amplitude of the pulses will not decrease, just the duty factor…

The next question is: how will you generate the signal to drive the Pmod Amp2. I see two possible options:

Using an AD convertor Pmod (ex. Pmod DA2). The PmodAmp2 would be cascaded into Pmod DA2.

Using a PWM modulator.

In both cases, you can adjust the volume by multiplying the digital sample values with a “volume” constant.  

      

Link to comment
Share on other sites

Thank you all for replying!

@elodg Thanks for the tip! I was indeed using the vivado library IP core. From opencores I presume you meant this controller? https://opencores.org/projects/sdcard_mass_storage_controller

If so, it does look promising, since it will basically be a direct hardware link to the SD card (if I am reading this correctly), currently it's running on the microBlaze and going through SPI. I just hope that the PmodSD supports the opencores controller.

I registered there and hope to download and test the code soon! It appears to be written in verilog, hopefully that wont clash with my vhdl code.

@MirceaDabacan Thanks for the explanation! I will search for some low power speakers to use with the AMP2 that I have right now since I couldn't find the max vpp specs of my JBL charge 2+. Your suggestion for the I2S2 is also a very interesting solution and if I do want to hook up a separate amplifier then I will definitely look into that module!

 

@D@n Thanks for the suggestion! Creating a high speed buffer, with a much larger capacity than the RAM that is available on my basys 3 is very interesting! Considering that the data files are about 13 MB worth of samples per track, I could easily load the music from the SD card minute by minute, giving me ample time to continuously buffer during playback.

 

Thanks for the support! Much appreciated! 

I will post back with my new findings!

 

Jonathan

Link to comment
Share on other sites

@elodg  It has been a while and I have been trying to get low level reading from the SD card to work but I am having difficulties.

Right now I am trying to get the following SDHC controller working: https://github.com/ibm2030/SimpleSDHC

Basically it can only read in 512 byte blocks, which is perfectly fine for my application.

I have attached the files that I have so far but I think that something goes wrong during initialisation. I'm trying to evade Microblaze in order to save LUTs and memory but debugging vhdl code is very difficult with my Basys 3 because I have to use led's for everything. Sadly I also have little to no experience with testbenches.

I'm thinking of moving back to Microblaze but keeping the SD controller in vhdl (to keep it low level and prevent a lot of overhead due to file management) and direct the I/O towards the Microblaze softcore in order to make debugging easier and get more control over the code (I come from C and C++ coding and the VHDL structure is sometimes quite tricky for me if I have to perform sequential actions, such as reading from an SD card.).

 

All suggestions are more than welcome!

 

Thanks!

 

Jonathan

SD_Com_Receiver.vhd SD_Com_Top.vhd sd_spi.vhd testbench_sd_spi.vhd

Link to comment
Share on other sites

@Jonathan.O,

I am seeing SPI signals in the code, not SD native. I though the whole point of this exercise is to have the interface with the lowest latency.

In any case you have to get the init sequence right first. Either use ILA and Vivado Hardware Manager to debug the sequence, or switch back to Microblaze and software for easy debugging. Honestly I would do Microblaze just to have file system support.

The init sequence is complicated with several modes and states the SD card can be in, wait times, status polls which are not easy got get right, especially in VHDL. Also confirm the clock speed is in the init range until the card is able to accept the maximum frequency.

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...