Page 1 of 1

PocketBeagle driving VS1063

Posted: Sun 2020-02-23 9:33
by vtech
Hello all,

This is my first time posting, so please bear with me as i'm just diving into some uncharted waters.

I have a PocketBeagle connected to an Adafruit Audio Breakout ( I had a manufacturing facility replace the stock VS1053 with a VS1063 because I need the capability to record MP3 files. I used the same breakout with an Arduino Micro with success using Adafruit's libraries that are a part of the Arduino IDE, but I am trying to migrate to the PocketBeagle because I need to expand capabilities. I connected the SPI pins MOSI, MISO, CLK between the two boards, and am using GPIOs on the PocketBeagle to observe DREQ and XDCS and driving RESET and CS. I used the player1063.c example as a baseline checkout and implemented ReadSpiByte and WriteSpiByte and am failing the basic VSInitSoftware routine when I try to write the values 0xABAD and 0x7E57 to the SCI_AICTRL1 and SCI_AICTRL2. I am reading back 0xFFs constantly and I don't seem to understand why. I know this is a bit vague and I can post code, but before I do I thought I'd lay it out here first and see what you guys need of me. Sorry for the newbness of the question.

Re: PocketBeagle driving VS1063

Posted: Mon 2020-02-24 11:04
by pasi
The first thing is to check the operation of xCS, and see that xDCS is high. Also check the SPI clock polarity.

Also note that SCI operations do not work if xRESET is low, or the oscillator is not running for some other reason.

Do you see DREQ going high, and 1.2V in RCAP/GBUF/LEFT/RIGHT?

Re: PocketBeagle driving VS1063

Posted: Mon 2020-02-24 19:02
by vtech
As a follow up, I successfully got it working. I was using the CS from from the PocketBeagle associated with the SPI interface, but instead chose a separate GPIO to perform the CS when DREQ went HIGH. After I did that it all just worked.

As a side note, the PocketBeagle doesn't allow for a SPI_NO_CS option which is what prompted me to change to a different GPIO for CS. Below is my code for anyone this might help trying to implement WriteSpiByte. I ended up just commenting out the setup of SPI mode since the default was just what I needed.

Code: Select all

void WriteSpiByte (u_int8 data) {

  int ret = 0;
  int fd;

  fd = open(device_spi_2, O_RDWR);

  /* SPI Mode */
  //ret = ioctl(fd, SPI_IOC_WR_MODE, SPI_CS_HIGH|SPI_MODE_0|SPI_NO_CS);
  if (ret < 0)
    printf("Byte Transmit Error ... 1\n");

  /* Set Bits per word */
  ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
  if (ret < 0)
    printf("Byte Transmit Error ... 2\n");

  /* Set MAX Xfer speed */
  ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed);
  if (ret < 0)
    printf("Byte Transmit Error ... 3\n");

  /* Transfer the byte */
  u_int8 tx[] = { data };
  u_int8 rx[1] = { };
  struct spi_ioc_transfer tr = {
	  .tx_buf = (unsigned long)tx,
	  .rx_buf = (unsigned long)rx,
	  .len = 1,
	  .delay_usecs = 0,
	  .speed_hz = speed,
	  .bits_per_word = bits,

  ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);

  if (ret < 0)
    printf("Byte Transmit Error ... \n");