Mikromedia PIC24FJ256GB110 VS1053

Writing software for systems that use VLSI Solution's devices as slave codecs to a host microcontroller.
btommo
User
Posts: 14
Joined: Tue 2019-05-21 11:41

Re: Mikromedia PIC24FJ256GB110 VS1053

Post by btommo »

further waveforms

Never mind I found the issue it was in my Write SCI routine, below I received from terminal after correcting a mistake I made with data && 0xFF instead of data & 0xFF.

Hex Result: 4800

Hex Result: ABAD

Hex Result: 7E57

Hex Result: ABAD

Hex Result: 7E57

Hex Result: 48

Chip is VS1053

I have run into another issue where the plugin starts loading and then stops after a number of seconds and doesn't seems to move onto the next line and the PIC no longer goes into a timer interrupt routine which I've used to toggle a pin. I've also printed a line before and after the plugin load but only the line before is shown. Watchdog timer has not been enabled for this.

Code: Select all

printf("Loading Plugin!\r\n");
  LoadPlugin(plugin, sizeof(plugin)/sizeof(plugin[0]));
  printf("Finished!\r\n");
Hex Result: 4800

Hex Result: ABAD

Hex Result: 7E57

Hex Result: ABAD

Hex Result: 7E57

Hex Result: 48

Chip is VS1053

Loading Plugin!

Below is load plugin routine.

Code: Select all

void LoadPlugin(const u_int16 *d, u_int16 len) {
  int i = 0;

  while (i<len) {
    unsigned short addr, n, val;
    addr = d[i++];
    n = d[i++];
    if (n & 0x8000U) { /* RLE run, replicate n samples */
      n &= 0x7FFF;
      val = d[i++];
      while (n--) {
        WriteSci(addr, val);
      }
    } else {           /* Copy run, copy n samples */
      while (n--) {
        val = d[i++];
        WriteSci(addr, val);
      }
    }
  }
}
Fixed, I had to declare plugin as static rather than const (I originally had memory issues with const). Never mind, I have a feeling this isn't the solution, the plugin seems to be loading in no time at all.
Attachments
MISO SCLK 090522.JPG
MISO SCLK 090522.JPG (63.77 KiB) Viewed 1746 times
MOSI SCLK 090522.JPG
MOSI SCLK 090522.JPG (64.5 KiB) Viewed 1746 times
MOSI SCLK 2 090522.JPG
MOSI SCLK 2 090522.JPG (69.3 KiB) Viewed 1746 times
MISO SCLK 2 090522.JPG
MISO SCLK 2 090522.JPG (70.47 KiB) Viewed 1746 times
User avatar
pasi
VLSI Staff
Posts: 2092
Joined: Thu 2010-07-15 16:04

Re: Mikromedia PIC24FJ256GB110 VS1053

Post by pasi »

If it takes no time, print the length parameter in LoadPlugin() to see that it is correct.

You could perhaps try without loading the patches package to get everything working first.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
btommo
User
Posts: 14
Joined: Tue 2019-05-21 11:41

Re: Mikromedia PIC24FJ256GB110 VS1053

Post by btommo »

I printed both the addr and val variables and seemed to match up to the values seen in the plugin array and also the length was 4667 which matches the plugin size defined in the .plg file, I do speed up to 2.66MHz after setting the clock to 12.288MHz. seems to work but uses a lot of data memory.

Attached is image of terminal output. Now to figure out reading MP3 file and forwarding to encoder.

Using Panu's hello example for VS1003B I've managed to play the hello array successfully.
Attachments
Plugin.JPG
Plugin.JPG (94.17 KiB) Viewed 1730 times
btommo
User
Posts: 14
Joined: Tue 2019-05-21 11:41

Re: Mikromedia PIC24FJ256GB110 VS1053

Post by btommo »

Hi Pasi,

Over the last few days I've managed to play a 48kbps by filling two buffers in a function in the main routine and send a byte every 85uS in a timer interrupt when a flag is set. I've tried to play a 124kbps by sending a byte over timer interrupt with the interrupt occurring at (1/kbps)*4 similar to how I calculated the 48kbps interrupt but the audio appears slow and slightly choppy. Reducing the timer interrupt speeds the message up but sound still appears to be "choppy", the sampling rate of the file is 48KHz. Do you have any advice regarding this?
User avatar
pasi
VLSI Staff
Posts: 2092
Joined: Thu 2010-07-15 16:04

Re: Mikromedia PIC24FJ256GB110 VS1053

Post by pasi »

If your DREQ handling works, you should not need to "time" the data transfer. Just check DREQ before sending each 32 bytes, and wait if it's low. Reread your code carefully -- you may think you're checking DREQ, but an extra or missing parenthesis or semicolon might change the meaning of your code.

Does your software ever see DREQ low? (Or high for that matter?)

Check that xTEST is pulled high to connected to IOVDD.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
btommo
User
Posts: 14
Joined: Tue 2019-05-21 11:41

Re: Mikromedia PIC24FJ256GB110 VS1053

Post by btommo »

You are correct, timer interrupt time doesn't seem to make a difference to the 48kbps but the 124 kbps sample remains slow and choppy. Program does check for DREQ before sending the next byte. XTEST is connected to IOVDD and AVDD. I put in a printf function to check for DREQ low and it see's it go low and high.
User avatar
pasi
VLSI Staff
Posts: 2092
Joined: Thu 2010-07-15 16:04

Re: Mikromedia PIC24FJ256GB110 VS1053

Post by pasi »

If it's slow, then either:
- The decoder is not decoding it quickly enough. Do you have SCI_CLOCKF set? E.g. 2.5x should be enough for vs1053b to decode all mp3 files.
- You're not providing the data quickly enough. What's your storage?

After you have written SCI_CLOCKF, you can probably increase your SPI clock speed.
btommo wrote: Wed 2022-05-18 13:13XTEST is connected to IOVDD and AVDD.
You use the same regulator for AVDD and IOVDD?
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
btommo
User
Posts: 14
Joined: Tue 2019-05-21 11:41

Re: Mikromedia PIC24FJ256GB110 VS1053

Post by btommo »

in the Initialisation software I write the below to SCI_CLOCKF.

Code: Select all

WriteSci(SCI_CLOCKF,
           HZ_TO_SC_FREQ(12288000));
The MIKROELECTRONIKA MIKROMEDIA board has a 12.288MHz crystal for the VS1053

I'm using two 512 buffers filling both buffers and then setting a flag to transmit each byte in the timer interrupt, when the first buffer ends the second buffer starts to transmit while the first buffer fills again.

seeing DREQ go low means I am transmitting fast enough correct?
You use the same regulator for AVDD and IOVDD?
It was Mikroelectronicas decision, using it as a starting point for a new design, has to introduce an external SD breakout board so seperate SPIs are used, one for decoder and one for SD card.

Ignore me, I commented out something that was needed, all works perfect now!

Thanks.
User avatar
pasi
VLSI Staff
Posts: 2092
Joined: Thu 2010-07-15 16:04

Re: Mikromedia PIC24FJ256GB110 VS1053

Post by pasi »

btommo wrote: Wed 2022-05-18 13:58in the Initialisation software I write the below to SCI_CLOCKF.

Code: Select all

WriteSci(SCI_CLOCKF, HZ_TO_SC_FREQ(12288000));
This sets the base XTALI value, but not the internal clock multiplier (PLL). The vs1053b will then run with 1.0x clock, which is not enough for higher bitrates and samplerates in stereo.

12.288MHz is also the default, so you can leave the XTAL control value at 0. So, e.g.

Code: Select all

WriteSci(SCI_CLOCKF, 0x6000); /* 3.0x clock */
If it works now, SCI_CLOCKF is probably written in the code you added back.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
Post Reply