nrf52 master VS1053 slave
Posted: Sat 2022-05-14 1:12
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
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