nrf52 master VS1053 slave

Writing software for systems that use VLSI Solution's devices as slave codecs to a host microcontroller.
Post Reply
cbrisebois
User
Posts: 10
Joined: Sat 2022-05-14 0:54

nrf52 master VS1053 slave

Post by cbrisebois »

Hello,

I am trying to establish my nrf52840 chip as master over the VS1053b to enable audio recording and playback features in my device. I am having trouble confirming initialization of the VS1053b. Specifically, when I preform a read operation for the serial command interface (SCI) I receive either no signal or garbage on the slave out (MISO) line. I have written my board specific driver for the VS1053 chip according the instructions as presented in two documents published by VSLI solutions, "VS10XX APPNOTE: CONNECTING SPI BUSES" and "VS1053 APPNOTE: PLAYBACK AND RECORDING". Below are snips of code regarding, a sample SCI write/read sanity check, my SPI initialization, and my WriteSCI function. I am using the 7-pin topology outlined in "VS10XX APPNOTE: CONNECTING SPI BUSES" (I have triple checked wiring).

/*** sample SCI read/write sanity check ***/
WriteSci(SCI_MODE, SM_SDINEW|SM_SDISHARE|SM_TESTS|SM_RESET);
nrf_delay_ms(10);
uint16_t sci_mode = ReadSci(SCI_MODE);

/*** SPI initialization ***/
nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
spi_config.sck_pin = SPI_SCK_PIN;
spi_config.miso_pin = SPI_MISO_PIN;
spi_config.mosi_pin = SPI_MOSI_PIN;
spi_config.ss_pin = SPI_MCS_PIN;
APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));

/*** WriteSCI ***/
void WriteSci(uint8_t addr, uint16_t data) {
while(!nrf_gpio_pin_read(SPI_DREQ_PIN));
uint8_t m_tx_buf[] = {SCI_WRITE_FLAG, addr, (uint8_t)(data >> 8), (uint8_t)(data & 0xFF)};
nrf_gpio_pin_clear(SPI_MCS_PIN);
APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf,sci_write_len, NULL, 0));
nrf_gpio_pin_set(SPI_MCS_PIN);
}

I have confirmed that the data sent over the SI (MOSI) line is correct with my oscilloscope. Please let me know if you see anything glaringly wrong, I'm pretty novice so I'm hoping my issue has a pretty simple fix.

Cheers,
Connor
User avatar
pasi
VLSI Staff
Posts: 1984
Joined: Thu 2010-07-15 16:04

Re: nrf52 master VS1053 slave

Post by pasi »

Hi,
The first things to check are that
- You don't have xCS and xDCS asserted (low) at the same time.
- xTEST is pulled high or connected to IOVDD.
- The SPI clock speed is low enough with the correct clock polarity.

After reset you should get values from SCI_MODE, SCI_STATUS, and SCI_AUDATA without needing to write.

See the recent thread: viewtopic.php?f=11&t=2950 , maybe some of your issues are similar.

Where are you setting sci_write_len in SciWrite? If you have issues with SciRead(), what does it look like?
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
cbrisebois
User
Posts: 10
Joined: Sat 2022-05-14 0:54

Re: nrf52 master VS1053 slave

Post by cbrisebois »

Hello, thank you for the reply.

I checked my assertions of xCS and xDS and re-timed them to reflect the VS1053b datasheet. I also slowed the clock speed. This fixed my problem and I can read/write to the chip's registers as desired. Thank you for your recommendations.

Cheers,
Connor
Post Reply