ΣSigmaStudio Ask AI Русский Log in

Controlling SigmaStudio Cell via SPI Slave

SigmaDSP & SigmaStudio demijulez Jan 23, 2024 00:00 3 replies Original on forum ↗
Subscribe
demijulez Question
Jan 23, 2024 00:00

Hello,

I am planning to interface a ADAU1452 with a STM32 via SPI.

I am currently programming the ADAU1452 with Sigmastudio via USBi. However, for my Project I need to control the volume of the ADAU1452, so I use a "Adjustable Gain" Cell. During operation, the STM32 should set the volume of the Adjustable Gain Cell repeadetly.

The ADAU1452 should be Set as a SPI Slave. Both the USBi and the STM32 are set to SPI Master and are connected in parallel to the same Pins (SS, SCLK, MISO, MOSI). After programming the SigmaStudio file to the Flash via USBi, the USBi will be disconnected.

What would be the most easy way to implement the SPI Slave feature? I guess there is either:

- some way to write via SPI directly to the RAM of the ADAU1452 and somehow identify where in the RAM the volume value of the Adjustable Gain is located at (Probably in the building/linking log of Sigmastudio)

- The possibility to define an SPI command inside SigmaSudio, which can read values sent from SPI and then adapt the Adjustable Gain block inside SigmaStudio

Unfortunately I didn't quite understand the Datasheet of the ADAU1452 (specifically the SPI Slave Section) and I am also quite new to the SigmaStudio.

Thanks a lot in Advance.

Best regards

Julian

Audio Signal Processors

adau1452

Audio Products

software

AnalogStudio 4.7

spi communication

sigmastudio

SigmaDSP Audio Processors

Show More

Harishgowtham Reply
Jan 23, 2024 00:00

Hello Julian,

The one issue that you will need to address will be the nature of SPI to not be friendly towards multiple masters on one bus. Since the SPI master will be pulling the lines up, you will need to find a workaround -- if your microcontroller will allow you to tristate the SPI lines when not in use, that would work. Alternately, you could install jumpers so that the microcontroller could be disconnected from the SPI bus when the USBi is connected. Please refer this post for a switch or Mux based solution.

demijulez said:
- some way to write via SPI directly to the RAM of the ADAU1452 and somehow identify where in the RAM the volume value of the Adjustable Gain is located at (Probably in the building/linking log of Sigmastudio)

Yes, you should design the schematic and compile it in sigma studio, then export the system files. You will find that parameter (vol controller) address in the PARAM.h file. You can have that address and access the RAM from your uC via SPI. This must be the easy and direct way. You can directly write to the respective block's address and change the value.

Please note that initially the slave control port is in I2C mode by default, you have to toggle the SS pin three times or write three dummy writes to put the port into the SPI mode. Once it is put into the SPI mode then you can't go back to I2C mode without a power cycle or reset.

Please have a look at this uC interfacing page here. Please also have a look at the IPAT feature here if you need a fixed address. This is because the parameter's address may vary after every compilation, or a new block is added/removed in the schematic.

Kindly do reply if you have any questions.

Regards,

Harish

DaveThib Reply
Jan 24, 2024 00:00

Hello Julian,

This is actually really simple. There are several ways to do this. You can export the system files and import all the headers and code into your program but this is super complicated if all you want to do it adjust one gain control. I will get you some more info soon.

First, I want to address the hardware aspect. You cannot connect together two SPI master ports. One of them needs to get "out of the way" by tri-stating any outputs. That would be the SCK, SS and MOSI lines. Some controllers can easily tri-state certain pins. You can also do it with hardware switches to disconnect the microcontroller when the USBi is connected. There is a 5V line on the USBi connector that you can use to drive a transistor to either go to a GPIO of your controller or to change logic lines for bus isolators. Many ways to do it but you do not want two things trying to drive the same line. Not good!

Meanwhile, learn about the Capture Window and there you can see how SigmaStudio communicates with the DSP which is exactly how you will do it with the microcontroller. The data parameter for the volume control is a gain factor. That gain factor is used to multiply the audio in to get the level of the audio out.

More later...

Dave T

DaveThib Reply
Jan 24, 2024 00:00

Sorry Harish for the repeated reply. Your reply did not show up on my browser until AFTER I submitted my reply.

Dave T