SPI problems interacting with mcp3208 ADC

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Has thanked: 3 times
Been thanked: 3 times

SPI problems interacting with mcp3208 ADC

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: SPI problems interacting with mcp3208 ADC

Post 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
User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Has thanked: 3 times
Been thanked: 3 times

Re: SPI problems interacting with mcp3208 ADC

Post by DeusExMachina »

The problem was in noisy ground connection of logic analisator probe.
Post Reply