<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/35862/vs1053-and-nrf52832</link><description>Hello. I have SMARTMP3 Board and NRF52832. The vs1053 works fine on the arduino. But it doesn&amp;#39;t work on the nrf52832. I use these connections: #define SCK_PIN 3 #define MOSI_PIN 4 #define MISO_PIN 28 #define CS_PIN 24 #define MP3_RESET 27 #define MP3_DREQ</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 04 Jul 2018 14:45:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/35862/vs1053-and-nrf52832" /><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/139003?ContentTypeID=1</link><pubDate>Wed, 04 Jul 2018 14:45:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc35e0af-c20a-4172-92af-eac0b304b450</guid><dc:creator>Anar</dc:creator><description>&lt;p&gt;Have just solved this problem.&lt;br /&gt;&lt;br /&gt;The overrun character was adding the 0xFF byte, which vs1053e recognizes as command and when I was reading the register after that with my 0xFF command it was just empty!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/139002?ContentTypeID=1</link><pubDate>Wed, 04 Jul 2018 14:42:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83ab1010-c2fa-43c6-9900-71ce74cce042</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;It could be that you&amp;#39;re not getting the same results because you&amp;#39;re sending the commands in 4 separate transactions. So you could try to do this in&amp;nbsp;Mp3ReadRegister()&amp;nbsp;&lt;/p&gt;
&lt;p&gt;uint8_t tx_buffer[4] ={0x03,0x01,0xFF,0xFF};&lt;/p&gt;
&lt;p&gt;uint8_t rx_buffer[4] ={0};&lt;/p&gt;
&lt;p&gt;APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;m_spi1, tx_buffer, sizeof(tx_buffer), rx_buffer, sizeof(rx_buffer)));&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138984?ContentTypeID=1</link><pubDate>Wed, 04 Jul 2018 13:25:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f95329b2-2f22-4c1f-bae5-858fef92c04e</guid><dc:creator>Anar</dc:creator><description>&lt;p&gt;0x03 means that it will be a reading operation&lt;br /&gt;0x01 - register that I will read&lt;br /&gt;0xFF - getting&amp;nbsp;first byte from register&lt;br /&gt;0xFF - getting second byte from register&lt;br /&gt;&lt;br /&gt;and the result should be 0x48 (tested it on the arduino, but on the nrf52 it returns 0)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Hmm...Okay I will do the same on the arduino.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138981?ContentTypeID=1</link><pubDate>Wed, 04 Jul 2018 13:22:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec028487-12e5-40b0-adf9-c70da51513c9</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Ok, so&amp;nbsp;you&amp;#39;re&amp;nbsp;seeing&amp;nbsp;&lt;br /&gt;&lt;br /&gt;MOSI: 0x03 0x01 0xFF 0xFF 0xFF&amp;nbsp;0xFF&lt;/p&gt;
&lt;p&gt;MISO: 0xFF 0xFF&amp;nbsp;0xFF&amp;nbsp;0xFF&amp;nbsp;0xFF&amp;nbsp;0xFF&lt;/p&gt;
&lt;p&gt;which is exactly what the code is supposed to do, at least from a MOSI viewpoint, I do not know what the&amp;nbsp;vs1053 should respond to these value. My suggestion would now be to perform a trace of the VS1053 when your sending the same commands with the Arduino and then compare the trace to this one.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138976?ContentTypeID=1</link><pubDate>Wed, 04 Jul 2018 13:10:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7913d9d7-964e-48f2-a20c-0e72a3f7ebb0</guid><dc:creator>Anar</dc:creator><description>&lt;p&gt;Sorry, the previous one was wrong. I have made new one. Here is the results:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/result.csv"&gt;devzone.nordicsemi.com/.../result.csv&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138899?ContentTypeID=1</link><pubDate>Wed, 04 Jul 2018 08:14:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56661c8f-3ba3-4796-b27a-8fb1b78daa62</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;So from you main() code I see that you&amp;#39;re performing the following SPI transactions&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;&amp;#160; APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;m_spi1, (uint8_t *)0xFF, sizeof(uint8_t), NULL, sizeof(uint8_t)));

&amp;#160; int k = Mp3ReadRegister(SCI_STATUS);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;where&amp;nbsp;Mp3ReadRegister is called with&amp;nbsp;SCI_STATUS(0x01) as an argument.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint8_t Mp3ReadRegister(uint8_t addressbyte) {
  while (!nrf_gpio_pin_read(MP3_DREQ)) {}; //Wait for DREQ to go high indicating IC is available
   nrf_gpio_pin_clear(MP3_XCS); //here
  nrf_delay_ms(10);
  //SCI consists of instruction byte, address byte, and 16-bit data word.
  APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;m_spi1, (uint8_t *)0x03, sizeof(uint8_t), NULL, sizeof(uint8_t)));
  APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;m_spi1, &amp;amp;addressbyte, sizeof(uint8_t), NULL, sizeof(uint8_t)));

  APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;m_spi1, (uint8_t *)0xFF, sizeof(uint8_t), &amp;amp;rx_buffer[0], sizeof(uint8_t)));
  while (!nrf_gpio_pin_read(MP3_DREQ)) {}; //Wait for DREQ to go high indicating IC is available
  APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;m_spi1, (uint8_t *)0xFF, sizeof(uint8_t), &amp;amp;rx_buffer[1], sizeof(uint8_t)));
  while (!nrf_gpio_pin_read(MP3_DREQ)) {}; //Wait for DREQ to go high indicating IC is available

  int resultvalue = rx_buffer[0] &amp;lt;&amp;lt; 8;
  resultvalue |= rx_buffer[1];

  nrf_gpio_pin_set(MP3_XCS); //here

  return resultvalue;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So from the first SPI transaction you should only see the single 0xFF byte being transmitted on the MOSI line and then you&amp;#39;ll get some garbage data back on the MISO line.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;From the transactions in&amp;nbsp;Mp3ReadRegister() you should see the 0x03 0xFF 0xFF and then you will get 3 bytes back on the MISO line. However you&amp;#39;re seeing&amp;nbsp;&lt;/p&gt;
&lt;p&gt;MOSI: 0xE4&amp;nbsp;0xE5 0xE6&amp;nbsp;&lt;/p&gt;
&lt;p&gt;MISO: 0xE5&amp;nbsp;0xE6&amp;nbsp;0xE7&lt;/p&gt;
&lt;p&gt;which does not match any of the transactions we&amp;#39;re expecting, so there is something that is not right. Can you configure the Salea analyzer to start capturing from the point where the&amp;nbsp;MP3_XDCS pin goes high so that we get the first transaction as well? You can also attach the the logic trace file to the case instead of posting a screenshot.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138826?ContentTypeID=1</link><pubDate>Tue, 03 Jul 2018 17:39:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f890ed48-8282-4f76-9455-f18a28eec996</guid><dc:creator>Anar</dc:creator><description>&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/Pasted-File-at-July-3_2C00_-2018-7_5F00_22-PM.png" /&gt;&lt;br /&gt;&lt;br /&gt;This is what I got with this code&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA
 * 
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 * 
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 * 
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 * 
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 * 
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 */
/** @file
 * @defgroup fatfs_example_main main.c
 * @{
 * @ingroup fatfs_example
 * @brief FATFS Example Application main file.
 *
 * This file contains the source code for a sample application using FAT filesystem and SD card library.
 *
 */

#include &amp;quot;SEGGER_RTT.h&amp;quot;
#include &amp;quot;bsp.h&amp;quot;
#include &amp;quot;diskio_blkdev.h&amp;quot;
#include &amp;quot;ff.h&amp;quot;
#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;nrf_block_dev_sdc.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;

#include &amp;quot;nrf_drv_spi.h&amp;quot;
#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

#define FILE_NAME &amp;quot;NORDIC.TXT&amp;quot;
#define TEST_STRING &amp;quot;SD card example.&amp;quot;

#define SPI_INSTANCE 1

#define SDC_SCK_PIN 3   ///&amp;lt; SDC serial clock (SCK) pin. 25   14
#define SDC_MOSI_PIN 4  ///&amp;lt; SDC serial data in (DI) pin. 23  13
#define SDC_MISO_PIN 28 ///&amp;lt; SDC serial data out (DO) pin. 24 12
#define SDC_CS_PIN 24   ///&amp;lt; SDC chip select (CS) pin. 22    11

#define MP3_RESET 27
#define MP3_DREQ 23
#define MP3_XCS 24
#define MP3_XDCS 25 //Data Chip Select / BSYNC Pin

//VS10xx SCI Registers
#define SCI_MODE 0x00
#define SCI_STATUS 0x01
#define SCI_BASS 0x02
#define SCI_CLOCKF 0x03
#define SCI_DECODE_TIME 0x04
#define SCI_AUDATA 0x05
#define SCI_WRAM 0x06
#define SCI_WRAMADDR 0x07
#define SCI_HDAT0 0x08
#define SCI_HDAT1 0x09
#define SCI_AIADDR 0x0A
#define SCI_VOL 0x0B
#define SCI_AICTRL0 0x0C
#define SCI_AICTRL1 0x0D
#define SCI_AICTRL2 0x0E
#define SCI_AICTRL3 0x0F

static const nrf_drv_spi_t m_spi1 = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);

static uint8_t rx_buffer[] = {0, 0};
static FIL file;

typedef struct {
  uint16_t length;
  uint8_t data[32];
} fatfs_read_buffer_t;

static fatfs_read_buffer_t fatfs_read_buffer = {.length = 0, .data = {0x00}};

/**
 * @brief  SDC block device definition
 * */
NRF_BLOCK_DEV_SDC_DEFINE(
    m_block_dev_sdc,
    NRF_BLOCK_DEV_SDC_CONFIG(
        SDC_SECTOR_SIZE,
        APP_SDCARD_CONFIG(SDC_MOSI_PIN, SDC_MISO_PIN, SDC_SCK_PIN, SDC_CS_PIN)),
    NFR_BLOCK_DEV_INFO_CONFIG(&amp;quot;Nordic&amp;quot;, &amp;quot;SDC&amp;quot;, &amp;quot;1.00&amp;quot;));

/**
 * @brief Function for demonstrating FAFTS usage.
 */
static void fatfs_example() {
  static FATFS fs;
  static DIR dir;
  static FILINFO fno;

  FRESULT ff_result;
  DSTATUS disk_state = STA_NOINIT;

  // Initialize FATFS disk I/O interface by providing the block device.
  static diskio_blkdev_t drives[] =
      {
          DISKIO_BLOCKDEV_CONFIG(NRF_BLOCKDEV_BASE_ADDR(m_block_dev_sdc, block_dev), NULL)};

  diskio_blockdev_register(drives, ARRAY_SIZE(drives));

  NRF_LOG_INFO(&amp;quot;Initializing disk 0 (SDC)...&amp;quot;);
  for (uint32_t retries = 10; retries &amp;amp;&amp;amp; disk_state; --retries) {
    disk_state = disk_initialize(0);
  }
  if (disk_state) {
    NRF_LOG_INFO(&amp;quot;Disk initialization failed.&amp;quot;);
    return;
  }

  uint32_t blocks_per_mb = (1024uL * 1024uL) / m_block_dev_sdc.block_dev.p_ops-&amp;gt;geometry(&amp;amp;m_block_dev_sdc.block_dev)-&amp;gt;blk_size;
  uint32_t capacity = m_block_dev_sdc.block_dev.p_ops-&amp;gt;geometry(&amp;amp;m_block_dev_sdc.block_dev)-&amp;gt;blk_count / blocks_per_mb;
  NRF_LOG_INFO(&amp;quot;Capacity: %d MB&amp;quot;, capacity);

  NRF_LOG_INFO(&amp;quot;Mounting volume...&amp;quot;);
  ff_result = f_mount(&amp;amp;fs, &amp;quot;&amp;quot;, 1);
  if (ff_result) {
    NRF_LOG_INFO(&amp;quot;Mount failed.&amp;quot;);
    return;
  }

  NRF_LOG_INFO(&amp;quot;\r\n Listing directory: /&amp;quot;);
  ff_result = f_opendir(&amp;amp;dir, &amp;quot;/&amp;quot;);
  if (ff_result) {
    NRF_LOG_INFO(&amp;quot;Directory listing failed!&amp;quot;);
    return;
  }

  do {
    ff_result = f_readdir(&amp;amp;dir, &amp;amp;fno);
    if (ff_result != FR_OK) {
      NRF_LOG_INFO(&amp;quot;Directory read failed.&amp;quot;);
      return;
    }

    if (fno.fname[0]) {
      if (fno.fattrib &amp;amp; AM_DIR) {
        NRF_LOG_RAW_INFO(&amp;quot;   &amp;lt;DIR&amp;gt;   %s&amp;quot;, (uint32_t)fno.fname);
      } else {
        NRF_LOG_RAW_INFO(&amp;quot;%9lu  %s&amp;quot;, fno.fsize, (uint32_t)fno.fname);
      }
    }
  } while (fno.fname[0]);
  NRF_LOG_RAW_INFO(&amp;quot;&amp;quot;);

  NRF_LOG_RAW_INFO(&amp;quot;\n&amp;quot;);
  /*
    NRF_LOG_INFO(&amp;quot;Writing to file &amp;quot; FILE_NAME &amp;quot;...&amp;quot;);
    ff_result = f_open(&amp;amp;file, FILE_NAME, FA_READ | FA_WRITE | FA_OPEN_APPEND);
    if (ff_result != FR_OK)
    {
        NRF_LOG_INFO(&amp;quot;Unable to open or create file: &amp;quot; FILE_NAME &amp;quot;.&amp;quot;);
        return;
    }

    ff_result = f_write(&amp;amp;file, TEST_STRING, sizeof(TEST_STRING) - 1, (UINT *) &amp;amp;bytes_written);
    if (ff_result != FR_OK)
    {
        NRF_LOG_INFO(&amp;quot;Write failed\r\n.&amp;quot;);
    }
    else
    {
        NRF_LOG_INFO(&amp;quot;%d bytes written.&amp;quot;, bytes_written);
    }
          
    (void) f_close(&amp;amp;file);*/
  return;
}

void playMP3(char *fileName) {
  int need_data = 1;
  FRESULT ff_result;
  uint32_t bytes_read;
  fatfs_example();

  while (1) {
    ff_result = f_open(&amp;amp;file, fileName, FA_READ);

    if (ff_result != FR_OK) {
      NRF_LOG_INFO(&amp;quot;Unable to open file \n&amp;quot;);
      return;
    }

    //while(!nrf_gpio_pin_read(MP3_DREQ))
    nrf_delay_ms(10);
    {

      //If the MP3 IC is happy, but we need to read new data from the SD, now is a great time to do so
      if (need_data == 1) {
        if ((ff_result = f_read(&amp;amp;file, fatfs_read_buffer.data, fatfs_read_buffer.length, &amp;amp;bytes_read)) != FR_OK)
          break;
        //Data reading ----------------------------
        //if no data break-------------------------
        need_data = 0;
      }

      nrf_delay_ms(100); //Do NOTHING - sounds fine
    }

    if (need_data == 1) { //This is here in case we haven&amp;#39;t had any free time to load new data
      if ((ff_result = f_read(&amp;amp;file, fatfs_read_buffer.data, fatfs_read_buffer.length, &amp;amp;bytes_read)) != FR_OK)
        break;
      //Data read-----------------------------
      //if no data break----------------------
      need_data = 0;
    }

    //Once DREQ is released (high) we now feed 32 bytes of data to the VS1053 from our SD read buffer
    nrf_gpio_pin_clear(MP3_XDCS); //Select Data
    //for(int y = 0 ; y &amp;lt; sizeof(fatfs_read_buffer.data) ; y++)
    {
      // Send SPI byte
      nrf_drv_spi_transfer(&amp;amp;m_spi1, fatfs_read_buffer.data, sizeof(fatfs_read_buffer.data), rx_buffer, sizeof(rx_buffer));
    }

    nrf_gpio_pin_set(MP3_XDCS); //Deselect Data
    need_data = 1;              //We&amp;#39;ve just dumped 32 bytes into VS1053 so our SD read buffer is empty. Set flag so we go get more data
  }

  // while(!nrf_gpio_pin_read(MP3_DREQ)) ; //Wait for DREQ to go high indicating transfer is complete
  nrf_delay_ms(10);
  nrf_gpio_pin_set(MP3_XDCS); //Deselect Data

  //Close out this track

  NRF_LOG_INFO(&amp;quot;end of the song&amp;quot;);

  f_close(&amp;amp;file);
}

uint8_t Mp3ReadRegister(uint8_t addressbyte) {
  while (!nrf_gpio_pin_read(MP3_DREQ)) {}; //Wait for DREQ to go high indicating IC is available
   nrf_gpio_pin_clear(MP3_XCS); //here
  nrf_delay_ms(10);
  //SCI consists of instruction byte, address byte, and 16-bit data word.
  APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;m_spi1, (uint8_t *)0x03, sizeof(uint8_t), NULL, sizeof(uint8_t)));
  APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;m_spi1, &amp;amp;addressbyte, sizeof(uint8_t), NULL, sizeof(uint8_t)));

  APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;m_spi1, (uint8_t *)0xFF, sizeof(uint8_t), &amp;amp;rx_buffer[0], sizeof(uint8_t)));
  while (!nrf_gpio_pin_read(MP3_DREQ)) {}; //Wait for DREQ to go high indicating IC is available
  APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;m_spi1, (uint8_t *)0xFF, sizeof(uint8_t), &amp;amp;rx_buffer[1], sizeof(uint8_t)));
  while (!nrf_gpio_pin_read(MP3_DREQ)) {}; //Wait for DREQ to go high indicating IC is available

  int resultvalue = rx_buffer[0] &amp;lt;&amp;lt; 8;
  resultvalue |= rx_buffer[1];

  nrf_gpio_pin_set(MP3_XCS); //here

  return resultvalue;
}

//Write to VS10xx register
//SCI: Data transfers are always 16bit. When a new SCI operation comes in
//DREQ goes low. We then have to wait for DREQ to go high again.
//XCS should be low for the full duration of operation.
void Mp3WriteRegister(uint8_t addressbyte, uint8_t highbyte, uint8_t lowbyte) {
  //while(!nrf_gpio_pin_read(MP3_DREQ)) ; //Wait for DREQ to go high indicating IC is available
  nrf_delay_ms(10);
  uint8_t temp = 0x02;
  //SCI consists of instruction byte, address byte, and 16-bit data word.
  nrf_drv_spi_transfer(&amp;amp;m_spi1, &amp;amp;temp, sizeof(temp), rx_buffer, sizeof(rx_buffer));
  nrf_delay_ms(50);
  nrf_drv_spi_transfer(&amp;amp;m_spi1, &amp;amp;addressbyte, sizeof(addressbyte), rx_buffer, sizeof(rx_buffer));
  nrf_delay_ms(50);
  nrf_drv_spi_transfer(&amp;amp;m_spi1, &amp;amp;highbyte, sizeof(highbyte), rx_buffer, sizeof(rx_buffer));
  nrf_delay_ms(50);
  nrf_drv_spi_transfer(&amp;amp;m_spi1, &amp;amp;lowbyte, sizeof(lowbyte), rx_buffer, sizeof(rx_buffer));
  nrf_delay_ms(10);
}

//Set VS10xx Volume Register
void Mp3SetVolume(uint8_t leftchannel, uint8_t rightchannel) {
  Mp3WriteRegister(SCI_VOL, leftchannel, rightchannel);
}

void spi_event_handler(nrf_drv_spi_evt_t const *p_event,
    void *p_context) {
  //spi_xfer_done = true;
  NRF_LOG_INFO(&amp;quot;Transfer completed.&amp;quot;);
  if (rx_buffer[0] != 0) {
    NRF_LOG_INFO(&amp;quot; Received: %d&amp;quot;, rx_buffer);
  }
}

/**
 * @brief Function for main application entry.
 */
int main(void) {
  bsp_board_init(BSP_INIT_LEDS);

  APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
  NRF_LOG_DEFAULT_BACKENDS_INIT();

  SEGGER_RTT_Init();
  SEGGER_RTT_SetTerminal(0);

  //NRF_LOG_INFO(&amp;quot;\n\n\n\nFATFS example started. new8&amp;quot;);
  SEGGER_RTT_TerminalOut(0, &amp;quot;\nInitialization\n&amp;quot;);

  //fatfs_example();

  nrf_gpio_cfg_output(MP3_RESET);
  nrf_gpio_cfg_output(MP3_XDCS);
  nrf_gpio_cfg_output(MP3_XCS);
  nrf_gpio_cfg_input(MP3_DREQ, NRF_GPIO_PIN_PULLDOWN);

  nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
  spi_config.ss_pin = NRF_DRV_SPI_PIN_NOT_USED;
  spi_config.miso_pin = SDC_MISO_PIN;
  spi_config.mosi_pin = SDC_MOSI_PIN;
  spi_config.sck_pin = SDC_SCK_PIN;
  spi_config.frequency = SPI_FREQUENCY_FREQUENCY_K125;
  APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;m_spi1, &amp;amp;spi_config, NULL, NULL));

  nrf_gpio_pin_clear(MP3_RESET);
  nrf_gpio_pin_set(MP3_XDCS);
  nrf_gpio_pin_set(MP3_XCS);

  nrf_delay_ms(10);

  nrf_gpio_pin_set(MP3_RESET); //Bring up VS1053

  while (!nrf_gpio_pin_read(MP3_DREQ)) {
  };

  APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;m_spi1, (uint8_t *)0xFF, sizeof(uint8_t), NULL, sizeof(uint8_t)));

  nrf_delay_ms(10);

  //NRF_SPI0-&amp;gt;FREQUENCY = SPI_FREQUENCY_FREQUENCY_M4;

  //Mp3WriteRegister(SCI_CLOCKF, 0x60, 0x00); //Set multiplier to 3.0x

  int k = Mp3ReadRegister(SCI_STATUS);

  //NRF_LOG_INFO(&amp;quot;status = %d\n status2 = %d&amp;quot;, ((k &amp;gt;&amp;gt; 4) &amp;amp; 0x0F), k);
  char str[255];

  sprintf(str, &amp;quot;\nstatus = %d\n&amp;quot;, k);

  SEGGER_RTT_TerminalOut(0, str);

  //Mp3SetVolume(20, 20); //Set initial volume (20 = -10dB) LOUD

  //	fatfs_example();

  /*
  Mp3SetVolume(20, 20); //Set initial volume (20 = -10dB) LOUD
	
	int MP3Mode = Mp3ReadRegister(SCI_MODE);
  int MP3Status = Mp3ReadRegister(SCI_STATUS);
  int MP3Clock = Mp3ReadRegister(SCI_CLOCKF);
	
	Mp3WriteRegister(SCI_CLOCKF, 0x60, 0x00); //Set multiplier to 3.0x
	
	MP3Clock = Mp3ReadRegister(SCI_CLOCKF);
*/
  //playMP3(&amp;quot;track.mp3&amp;quot;);

  while (true) {
    __WFE();
  }
}

/** @} */&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138564?ContentTypeID=1</link><pubDate>Mon, 02 Jul 2018 15:11:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfc9bdbb-6586-475f-af03-a4447f2659dd</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;I am afraid that I am out of ideas here. I really need to see a trace of the SPI lines in order to figure out whats going on here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138257?ContentTypeID=1</link><pubDate>Fri, 29 Jun 2018 11:25:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33b613d2-0bce-4a68-a1a0-055a7e676485</guid><dc:creator>Anar</dc:creator><description>&lt;p&gt;In the arduino code I use SPI MODE 0, the same mode I have chosen in the NRF52.&lt;br /&gt;&lt;br /&gt;The vs1053 works well with arduino, I checked it 10 minutes ago, so the problem is definitely on the nrf side, just want to know what this problem can be related to?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138255?ContentTypeID=1</link><pubDate>Fri, 29 Jun 2018 11:21:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6b618d9-c12d-4eaa-b52f-c5e2cee22e3e</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;OK, its hard&amp;nbsp; to debug the issue without a trace of the SPI lines as we do not know if the problem is on the nrf side or the vs1053 side.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We need to check if the data in the SPI TX buffer is sent to the vs1053 or not. If the correct data is sent on the SPI lines, then&amp;nbsp;its either an issue&amp;nbsp; on the vs1053 side or it could be the nRF52 using thewrong SPI mode. You could try to&amp;nbsp; change the&amp;nbsp;.mode member (&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/group__nrf__drv__spi.html#gaffa6ae4610096303b0110c9d1e714251"&gt;nrf_drv_spi_mode_t&lt;/a&gt;) of&amp;nbsp;&amp;nbsp;nrf_drv_spi_config_t and see if that solves the issue.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138239?ContentTypeID=1</link><pubDate>Fri, 29 Jun 2018 09:26:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74968b50-2f42-4516-b4a2-05d33239cf41</guid><dc:creator>Anar</dc:creator><description>&lt;p&gt;Unfortunately I don&amp;#39;t have oscilloscope.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138236?ContentTypeID=1</link><pubDate>Fri, 29 Jun 2018 09:17:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a843f95-9120-4475-a658-3b2f2a1bd9b1</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;OK, thats one step in the right direction.&lt;/p&gt;
&lt;p&gt;Are you able to perform a logic trace of the SPI pins or scope them so that we can verify that the correct commands are sent to the&amp;nbsp;vs1053?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138228?ContentTypeID=1</link><pubDate>Fri, 29 Jun 2018 08:51:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9059b37-288b-4dda-a056-e23efb3f3a23</guid><dc:creator>Anar</dc:creator><description>&lt;p&gt;I have modified the code, so there are no hangs or errors anymore, however the result is the same - &amp;quot;0&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138178?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 15:28:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b6813c7-825b-4e44-a12a-2cd0594b73bb</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;According to&amp;nbsp;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/group__nrf__drv__spi.html#ga8502179e5c7d7a7da5104a4c1febe1e0"&gt;nrf_drv_spi_transfer&lt;/a&gt;&amp;nbsp;the 0x10 error code corresponds to:&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;NRF_ERROR_INVALID_ADDR&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;If the provided buffers are not placed in the Data RAM region.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;So maybe try doing this&lt;/p&gt;
&lt;p&gt;uint8_t tx_buffer = 0xFF&lt;br /&gt;&lt;br /&gt;APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;m_spi1, &amp;amp;tx_buffer , sizeof(uint8_t), &amp;amp;rx_buffer[0], sizeof(uint8_t)));&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138165?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 14:38:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c252cea-2ad4-464c-8695-8e08620dfb05</guid><dc:creator>Anar</dc:creator><description>&lt;p&gt;void app_error_handler_bare(unsigned int error_code=0x00000010)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138162?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 14:28:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a018dcf2-2585-4fe6-9650-dd7126814690</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;And what is the error code?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138154?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 13:56:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f708ef91-488c-4dfc-a537-43b5ee458244</guid><dc:creator>Anar</dc:creator><description>&lt;p&gt;Done.&lt;br /&gt;&lt;br /&gt;It gives me an error on the first transfer in Mp3ReadRegister();&lt;br /&gt;&lt;br /&gt;APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;m_spi1, (uint8_t *)0x03, sizeof(uint8_t), NULL, sizeof(uint8_t))); //here&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138123?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 12:53:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0ad4442-f8e5-4edb-9fcf-a311dea3ee04</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;OK, are you able to do a logic trace of the SPI lines?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also you should add&amp;nbsp;APP_ERROR_CHECKs to your&amp;nbsp;nrf_drv_spi_transfer() calls in&amp;nbsp;Mp3ReadRegister(), i.e.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;m_spi1, (uint8_t*)0xFF, sizeof(uint8_t), &amp;amp;rx_buffer[0], sizeof(uint8_t)));&lt;/p&gt;
&lt;p&gt;that way the code will assert if any of the transfers return an error code.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138093?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 11:47:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:125cb85c-791e-4dfd-a16f-017737fcbc44</guid><dc:creator>Anar</dc:creator><description>&lt;p&gt;Hi Bjorn,&lt;br /&gt;&lt;br /&gt;the connections are okay, because the SD card on the same board works fine.&lt;br /&gt;&lt;br /&gt;I should receive 0x48 (what I receive on the arduino with the same code), but I receive only 0.&lt;br /&gt;&lt;br /&gt;Here is my code :&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA
 * 
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 * 
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 * 
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 * 
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 * 
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 */
/** @file
 * @defgroup fatfs_example_main main.c
 * @{
 * @ingroup fatfs_example
 * @brief FATFS Example Application main file.
 *
 * This file contains the source code for a sample application using FAT filesystem and SD card library.
 *
 */


#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;bsp.h&amp;quot;
#include &amp;quot;ff.h&amp;quot;
#include &amp;quot;diskio_blkdev.h&amp;quot;
#include &amp;quot;nrf_block_dev_sdc.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;SEGGER_RTT.h&amp;quot;


#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;
#include &amp;quot;nrf_drv_spi.h&amp;quot;

#define FILE_NAME   &amp;quot;NORDIC.TXT&amp;quot;
#define TEST_STRING &amp;quot;SD card example.&amp;quot;

#define SPI_INSTANCE 1

#define SDC_SCK_PIN     3  ///&amp;lt; SDC serial clock (SCK) pin. 25   14
#define SDC_MOSI_PIN    4 ///&amp;lt; SDC serial data in (DI) pin. 23  13
#define SDC_MISO_PIN    28  ///&amp;lt; SDC serial data out (DO) pin. 24 12
#define SDC_CS_PIN      24   ///&amp;lt; SDC chip select (CS) pin. 22    11

#define MP3_RESET 27
#define MP3_DREQ 23
#define MP3_XCS 24
#define MP3_XDCS 25 //Data Chip Select / BSYNC Pin

//VS10xx SCI Registers
#define SCI_MODE 0x00
#define SCI_STATUS 0x01
#define SCI_BASS 0x02
#define SCI_CLOCKF 0x03
#define SCI_DECODE_TIME 0x04
#define SCI_AUDATA 0x05
#define SCI_WRAM 0x06
#define SCI_WRAMADDR 0x07
#define SCI_HDAT0 0x08
#define SCI_HDAT1 0x09
#define SCI_AIADDR 0x0A
#define SCI_VOL 0x0B
#define SCI_AICTRL0 0x0C
#define SCI_AICTRL1 0x0D
#define SCI_AICTRL2 0x0E
#define SCI_AICTRL3 0x0F

static const nrf_drv_spi_t m_spi1 = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);

static uint8_t rx_buffer[] = {0, 0};
static FIL file;

typedef struct {
    uint16_t length;
    uint8_t data[32];
} fatfs_read_buffer_t;

static fatfs_read_buffer_t fatfs_read_buffer = {.length = 0, .data = {0x00}};

/**
 * @brief  SDC block device definition
 * */
NRF_BLOCK_DEV_SDC_DEFINE(
        m_block_dev_sdc,
        NRF_BLOCK_DEV_SDC_CONFIG(
                SDC_SECTOR_SIZE,
                APP_SDCARD_CONFIG(SDC_MOSI_PIN, SDC_MISO_PIN, SDC_SCK_PIN, SDC_CS_PIN)
         ),
         NFR_BLOCK_DEV_INFO_CONFIG(&amp;quot;Nordic&amp;quot;, &amp;quot;SDC&amp;quot;, &amp;quot;1.00&amp;quot;)
);

/**
 * @brief Function for demonstrating FAFTS usage.
 */
static void fatfs_example()
{
    static FATFS fs;
    static DIR dir;
    static FILINFO fno;

    FRESULT ff_result;
    DSTATUS disk_state = STA_NOINIT;

    // Initialize FATFS disk I/O interface by providing the block device.
    static diskio_blkdev_t drives[] =
    {
            DISKIO_BLOCKDEV_CONFIG(NRF_BLOCKDEV_BASE_ADDR(m_block_dev_sdc, block_dev), NULL)
    };

    diskio_blockdev_register(drives, ARRAY_SIZE(drives));

    NRF_LOG_INFO(&amp;quot;Initializing disk 0 (SDC)...&amp;quot;);
    for (uint32_t retries = 10; retries &amp;amp;&amp;amp; disk_state; --retries)
    {
        disk_state = disk_initialize(0);
    }
    if (disk_state)
    {
        NRF_LOG_INFO(&amp;quot;Disk initialization failed.&amp;quot;);
        return;
    }

    uint32_t blocks_per_mb = (1024uL * 1024uL) / m_block_dev_sdc.block_dev.p_ops-&amp;gt;geometry(&amp;amp;m_block_dev_sdc.block_dev)-&amp;gt;blk_size;
    uint32_t capacity = m_block_dev_sdc.block_dev.p_ops-&amp;gt;geometry(&amp;amp;m_block_dev_sdc.block_dev)-&amp;gt;blk_count / blocks_per_mb;
    NRF_LOG_INFO(&amp;quot;Capacity: %d MB&amp;quot;, capacity);

    NRF_LOG_INFO(&amp;quot;Mounting volume...&amp;quot;);
    ff_result = f_mount(&amp;amp;fs, &amp;quot;&amp;quot;, 1);
    if (ff_result)
    {
        NRF_LOG_INFO(&amp;quot;Mount failed.&amp;quot;);
        return;
    }

    NRF_LOG_INFO(&amp;quot;\r\n Listing directory: /&amp;quot;);
    ff_result = f_opendir(&amp;amp;dir, &amp;quot;/&amp;quot;);
    if (ff_result)
    {
        NRF_LOG_INFO(&amp;quot;Directory listing failed!&amp;quot;);
        return;
    }

    do
    {
        ff_result = f_readdir(&amp;amp;dir, &amp;amp;fno);
        if (ff_result != FR_OK)
        {
            NRF_LOG_INFO(&amp;quot;Directory read failed.&amp;quot;);
            return;
        }

        if (fno.fname[0])
        {
            if (fno.fattrib &amp;amp; AM_DIR)
            {
                NRF_LOG_RAW_INFO(&amp;quot;   &amp;lt;DIR&amp;gt;   %s&amp;quot;,(uint32_t)fno.fname);
            }
            else
            {
                NRF_LOG_RAW_INFO(&amp;quot;%9lu  %s&amp;quot;, fno.fsize, (uint32_t)fno.fname);
            }
        }
    }
    while (fno.fname[0]);
    NRF_LOG_RAW_INFO(&amp;quot;&amp;quot;);
		
		NRF_LOG_RAW_INFO(&amp;quot;\n&amp;quot;);
/*
    NRF_LOG_INFO(&amp;quot;Writing to file &amp;quot; FILE_NAME &amp;quot;...&amp;quot;);
    ff_result = f_open(&amp;amp;file, FILE_NAME, FA_READ | FA_WRITE | FA_OPEN_APPEND);
    if (ff_result != FR_OK)
    {
        NRF_LOG_INFO(&amp;quot;Unable to open or create file: &amp;quot; FILE_NAME &amp;quot;.&amp;quot;);
        return;
    }

    ff_result = f_write(&amp;amp;file, TEST_STRING, sizeof(TEST_STRING) - 1, (UINT *) &amp;amp;bytes_written);
    if (ff_result != FR_OK)
    {
        NRF_LOG_INFO(&amp;quot;Write failed\r\n.&amp;quot;);
    }
    else
    {
        NRF_LOG_INFO(&amp;quot;%d bytes written.&amp;quot;, bytes_written);
    }
          
    (void) f_close(&amp;amp;file);*/
    return;
}


void playMP3(char* fileName)
{
  int need_data = 1; 
	FRESULT ff_result;
	uint32_t bytes_read;
	fatfs_example();

  while(1) {	        
            ff_result = f_open(&amp;amp;file, fileName, FA_READ);
					
            if (ff_result != FR_OK)
            {
							NRF_LOG_INFO(&amp;quot;Unable to open file \n&amp;quot;);
							return;
            }
		
    //while(!nrf_gpio_pin_read(MP3_DREQ)) 
						nrf_delay_ms(10);
			{ 

      //If the MP3 IC is happy, but we need to read new data from the SD, now is a great time to do so
      if(need_data == 1) {
				if((ff_result = f_read(&amp;amp;file, fatfs_read_buffer.data, fatfs_read_buffer.length, &amp;amp;bytes_read)) != FR_OK)
				break;
        //Data reading ----------------------------
        //if no data break-------------------------
        need_data = 0;
      }

      nrf_delay_ms(100); //Do NOTHING - sounds fine
    }


    if(need_data == 1){ //This is here in case we haven&amp;#39;t had any free time to load new data
			if((ff_result = f_read(&amp;amp;file, fatfs_read_buffer.data, fatfs_read_buffer.length, &amp;amp;bytes_read)) != FR_OK)
				break;
      //Data read-----------------------------
      //if no data break----------------------
      need_data = 0;
    }

    //Once DREQ is released (high) we now feed 32 bytes of data to the VS1053 from our SD read buffer
    nrf_gpio_pin_clear(MP3_XDCS); //Select Data
    //for(int y = 0 ; y &amp;lt; sizeof(fatfs_read_buffer.data) ; y++)
		{
      // Send SPI byte
			nrf_drv_spi_transfer(&amp;amp;m_spi1, fatfs_read_buffer.data, sizeof(fatfs_read_buffer.data), rx_buffer, sizeof(rx_buffer));
    }

    nrf_gpio_pin_set(MP3_XDCS); //Deselect Data
    need_data = 1; //We&amp;#39;ve just dumped 32 bytes into VS1053 so our SD read buffer is empty. Set flag so we go get more data
  }

 // while(!nrf_gpio_pin_read(MP3_DREQ)) ; //Wait for DREQ to go high indicating transfer is complete
	nrf_delay_ms(10);
  nrf_gpio_pin_set(MP3_XDCS); //Deselect Data
  
  //Close out this track
	
	NRF_LOG_INFO(&amp;quot;end of the song&amp;quot;);
	
	f_close(&amp;amp;file);
}


uint8_t Mp3ReadRegister (uint8_t addressbyte){
  while(!nrf_gpio_pin_read(MP3_DREQ)){}; //Wait for DREQ to go high indicating IC is available
  // nrf_gpio_pin_clear(MP3_XCS); //here
		nrf_delay_ms(10);
  //SCI consists of instruction byte, address byte, and 16-bit data word.
  nrf_drv_spi_transfer(&amp;amp;m_spi1, (uint8_t*)0x03, sizeof(uint8_t), NULL, sizeof(uint8_t));
  nrf_drv_spi_transfer(&amp;amp;m_spi1, &amp;amp;addressbyte, sizeof(uint8_t), NULL, sizeof(uint8_t));
	
  nrf_drv_spi_transfer(&amp;amp;m_spi1, (uint8_t*)0xFF, sizeof(uint8_t), &amp;amp;rx_buffer[0], sizeof(uint8_t));
	while(nrf_gpio_pin_read(MP3_DREQ)){}; //Wait for DREQ to go high indicating IC is available
  nrf_drv_spi_transfer(&amp;amp;m_spi1, (uint8_t*)0xFF, sizeof(uint8_t), &amp;amp;rx_buffer[1], sizeof(uint8_t));
	while(nrf_gpio_pin_read(MP3_DREQ)){}; //Wait for DREQ to go high indicating IC is available
	
  int resultvalue = rx_buffer[0] &amp;lt;&amp;lt; 8;
  resultvalue |= rx_buffer[1];
	
	//nrf_gpio_pin_set(MP3_XCS); //here
	
  return resultvalue;
}




//Set VS10xx Volume Register
void Mp3SetVolume(uint8_t leftchannel, uint8_t rightchannel){
  Mp3WriteRegister(SCI_VOL, leftchannel, rightchannel);
}


/**
 * @brief Function for main application entry.
 */
int main(void)
{
    bsp_board_init(BSP_INIT_LEDS);

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    SEGGER_RTT_Init ();
    SEGGER_RTT_SetTerminal(0);

    //NRF_LOG_INFO(&amp;quot;\n\n\n\nFATFS example started. new8&amp;quot;);  
    SEGGER_RTT_TerminalOut(0, &amp;quot;\nInitialization\n&amp;quot;);

    //fatfs_example();	  
	
          nrf_gpio_cfg_output(MP3_RESET);
	  nrf_gpio_cfg_output(MP3_XDCS);
	//  nrf_gpio_cfg_output(MP3_XCS);
	  nrf_gpio_cfg_input(MP3_DREQ, NRF_GPIO_PIN_PULLDOWN);
	
	  nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    spi_config.ss_pin   = MP3_XCS;
    spi_config.miso_pin = SDC_MISO_PIN;
    spi_config.mosi_pin = SDC_MOSI_PIN;
    spi_config.sck_pin  = SDC_SCK_PIN;
	  spi_config.frequency = SPI_FREQUENCY_FREQUENCY_M1;
    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;m_spi1, &amp;amp;spi_config, NULL, NULL));
		
		nrf_gpio_pin_clear(MP3_RESET);
		nrf_gpio_pin_set(MP3_XDCS);
		//nrf_gpio_pin_set(MP3_XCS);
		
		nrf_delay_ms(10);   
	
	  nrf_gpio_pin_set(MP3_RESET); //Bring up VS1053
		
		while(!nrf_gpio_pin_read(MP3_DREQ)){};
		
		nrf_drv_spi_transfer(&amp;amp;m_spi1, (uint8_t*)0xFF, sizeof(uint8_t), NULL, sizeof(uint8_t));
		
		nrf_delay_ms(10);
		
		//NRF_SPI0-&amp;gt;FREQUENCY = SPI_FREQUENCY_FREQUENCY_M4;
		
		//Mp3WriteRegister(SCI_CLOCKF, 0x60, 0x00); //Set multiplier to 3.0x
		
		int k = Mp3ReadRegister(SCI_STATUS);
		
		//NRF_LOG_INFO(&amp;quot;status = %d\n status2 = %d&amp;quot;, ((k &amp;gt;&amp;gt; 4) &amp;amp; 0x0F), k);
                char str[255];

                sprintf(str, &amp;quot;\nstatus = %d\n&amp;quot;, k);

                SEGGER_RTT_TerminalOut(0, str);
			
			
		
		//Mp3SetVolume(20, 20); //Set initial volume (20 = -10dB) LOUD
		
	//	fatfs_example();	
		
/*
  Mp3SetVolume(20, 20); //Set initial volume (20 = -10dB) LOUD
	
	int MP3Mode = Mp3ReadRegister(SCI_MODE);
  int MP3Status = Mp3ReadRegister(SCI_STATUS);
  int MP3Clock = Mp3ReadRegister(SCI_CLOCKF);
	
	Mp3WriteRegister(SCI_CLOCKF, 0x60, 0x00); //Set multiplier to 3.0x
	
	MP3Clock = Mp3ReadRegister(SCI_CLOCKF);
*/
 //playMP3(&amp;quot;track.mp3&amp;quot;);

    while (true)
    {
        __WFE();
    }
}

/** @} */
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: VS1053 and NRF52832</title><link>https://devzone.nordicsemi.com/thread/138092?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 11:43:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a8344a3-d883-44d2-b4a1-c62a445bf901</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Anar,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;please verify that your connections are correct and that&amp;nbsp;the correct&amp;nbsp;VSxxxx mode is set on the vs1053&lt;/p&gt;
&lt;p&gt;Are you able to perform a logic trace of the SPI pins so that we can verify that the correct commands are sent to the&amp;nbsp;vs1053?&lt;/p&gt;
&lt;p&gt;Lastly, please post the nRF52 code where you intialize the SPI driver and send data to the VS1053.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>