Page 1 of 1

SPI problems interacting with mcp3208 ADC

Posted: Tue May 01, 2012 7:01 pm
by DeusExMachina
in separate thread I launch this code:

Code: Select all

spiSelect(&SPID2);
spiStartExchange(&SPID2, 3, spi_tx_buff, spi_rx_buff);
chThdSleepMilliseconds(10);
spiUnselect(&SPID2);

SPI configured this way

Code: Select all

static const SPIConfig spicfg =
{
  NULL,
  /* HW dependent part.*/
  GPIOB,
  GPIOB_SPI2NSS,
  SPI_CR1_MSTR |  SPI_CR1_BR_0 | SPI_CR1_BR_1 | SPI_CR1_BR_2
};


when I use spiSend or spiReceive system halts.
But using spiStartExchange gets another problem - SS line doesn’t keep low during transfer, so I get junk tx and rx values.
Image

Re: SPI problems interacting with mcp3208 ADC

Posted: Tue May 01, 2012 7:19 pm
by Giovanni
Is the SPI2NSS line configured as GPIO push-pull output?

BTW, you don't need to specify SPI_CR1_MSTR, it is enforced internally.

Giovanni

Re: SPI problems interacting with mcp3208 ADC

Posted: Fri May 04, 2012 5:37 am
by DeusExMachina
The problem was in noisy ground connection of logic analisator probe.