VS1005 SPI MISO

Writing software that controls the system and peripherals such as displays, SD cards, Buttons, LEDs, Serial Ports etc.
Fridolin
Senior User
Posts: 20
Joined: Mon 2015-11-30 12:54

Re: VS1005 SPI MISO

Post by Fridolin » Thu 2015-12-10 12:20

is it a problem, that I do not pull up XCS0 after each byte? I can not do that because of my SPI CS hardware logic

D6 (XCS0) gets high after writing three bytes to io-expander
Attachments
scope_6.png
scope_6.png (19.72 KiB) Viewed 1144 times

User avatar
Henrik
VLSI Staff
Posts: 1041
Joined: Tue 2010-06-22 14:10

Re: VS1005 SPI MISO

Post by Henrik » Thu 2015-12-10 16:17

Hello,

XCS0 shouldn't affect what you can read; I just wanted to see the timings. They look ok.

After reading through your code, the only things I could think of are:

1) ini_uc(); Try changing these lines:

Code: Select all

   GpioSetAsPeripheral(0x10);   // set GPIO1_0 as peripheral (SPI.cs)
   GpioSetAsPeripheral(0x11);   // set GPIO1_1 as peripheral (SPI.scl)
   GpioSetAsPeripheral(0x12);   // set GPIO1_2 as peripheral (SPI.miso)
   GpioSetAsPeripheral(0x13);   // set GPIO1_3 as peripheral (SPI.mosi)
to

Code: Select all

   GpioSetAsInput(0x12);   // set GPIO1_2 as input (SPI.miso); this shouldn't really help, it's here just in case
   GpioSetAsPeripheral(0x10);   // set GPIO1_0 as peripheral (SPI.cs)
   GpioSetAsPeripheral(0x11);   // set GPIO1_1 as peripheral (SPI.scl)
   GpioSetAsPeripheral(0x12);   // set GPIO1_2 as peripheral (SPI.miso)
   GpioSetAsPeripheral(0x13);   // set GPIO1_3 as peripheral (SPI.mosi)
2) ini_uc(); Try uncommenting this so that you can be sure the software doesn't try to read from internal SPI:

Code: Select all

//PERIP(SYSTEMPD) &= ~SYSTEMPD_SFENA;
3) ioexp_read_reg(): Try changing the following code:

Code: Select all

   // 3rd
   PERIP(SPI0_DATA) = 0xff; // dummy

   while(PERIP(SPI0_STATUS) & SPI_ST_TXRUNNING){};
   
   data_tmp = PERIP(SPI0_DATA);
to

Code: Select all

   // 3rd
   PERIP(SPI0_DATA) = 0xff; // dummy

   data_tmp = PERIP(SPI0_STATUS);
   while(PERIP(SPI0_STATUS) & SPI_ST_TXRUNNING){};
   
   data_tmp = PERIP(SPI0_DATA);
This change may look weird, but the thing is that but SPI_ST_TXRUNNING turns on only two clock cycles after the write to SPI0_DATA, so if the compiler optimizes data writes to SPI0_DATA and first read from SPI0_STATUS so well that they occur on consecutive clock cycles, then the code will fail.

4) uc_init(); This doesn't affect your SPI problem, but if you have a 12.288 MHz external clock and want an exact 1 ms timer, you should write 6143 to TIMER_T0L, not 6000. If your clock is 12.000 MHz, write 5999.

Kind regards,
- Henrik
Good signatures never die. They just fade away.

Fridolin
Senior User
Posts: 20
Joined: Mon 2015-11-30 12:54

Re: VS1005 SPI MISO

Post by Fridolin » Mon 2015-12-14 10:53

Hallo Henrik,

thank you very much for your help. Strange thing now. Your solution doesn't help, so I tried to use spi1 instead of spi0 and changed my code (only spi0 to spi1) and now it is working fine :) If you need my code for troubleshooting I can provide it to you (maybe in my further project I have to use both)

Kind regards,
Fridolin

User avatar
Panu
VLSI Staff
Posts: 2428
Joined: Tue 2010-06-22 13:43

Re: VS1005 SPI MISO

Post by Panu » Tue 2015-12-15 7:05

Hi!

From my point of view this looks like it might be a bad solder contact on the MISO0 pin. I wonder if you would see a clean square waveform by repeatedly calling GpioSetPin(0x12,1) and GpioSetPin(0x12,0)... vo_gpio.h should be included.

-Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

Fridolin
Senior User
Posts: 20
Joined: Mon 2015-11-30 12:54

Re: VS1005 SPI MISO

Post by Fridolin » Fri 2016-01-15 8:55

Hi Panu,

I tried three different breakout-boards now. It’s always the same problem. So I tried to use the MISO pin as a simple input pin, this is working fine. :?
But doesn't matter, with SPI1 I don't have any problems.

Thanks for your Help. I think you can close this topic.

-Fridolin

User avatar
pasi
VLSI Staff
Posts: 1416
Joined: Thu 2010-07-15 16:04

Re: VS1005 SPI MISO

Post by pasi » Fri 2016-01-15 12:00

Maybe the internal/external SPI0 select is in the wrong state. This may be the case if you boot / use from the internal SPI FLASH.

Code: Select all

      PERIP(SYSTEMPD) &= ~SYSTEMPD_SFENA; /*De-select internal SPI.*/
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

Post Reply