cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong wiring for SPI? and SPI (MISO) not responding

MBolo.1
Associate III

Hello to everyone,

Were to start? Let me first try do describe the setup.

1. Using and STM32F446 chip on a custom board. The board has 2-32pins slots: Slot A and B.

2.For communication I'm using the SPI protocol.

3.For slot A using PE12(CKL); PE13(MISO)PE14(MOSI) and for slot B PB13(SCK), PB14(MISO) and PB15(MOSI)

4 Each slot has another 4 ADS connected in Slave Mode.

The interesting part.

First I tried to communicate with the first ADS from the slot A and after a bunch attempts and fails I start checking the schematics I found this Error in schematics

SPI_COnnections.JPG

MISO is connected to MOSI! that means that those 4 ADS from Slot A can not be used for moment. I decided to use the Slot B because that one looks connected properly and here I was going nowhere. I was just not getting any response from the ADS , below is the picture from logic annalizer

Capture3.JPG  a quick explanation: according to the documentation the ADS comunicates i 2 byte format. First tels what to do :Read or Write and the second the Address of the register.

So I decided to start with the basic one, READ the ID register (I named it numBytes ,read=0x20 and ID=0x00)  spi_ buf is just a buffer were the return info should be placed and here were it comes the best the return response on MISO from ADS is always 0.

Can anyone:

1. Explain why the Slot A has that weird wiring? Only thing that I found in documentation of STM is that in Master-Master mode the MOSI and MISO are bidirectional lines.

2. Why on the Slot B even with right wiring still no response from the ADS?

If any questions you have regardless the setup will try to response.

Thank you .

5 REPLIES 5
TDK
Guru

Initialize the pins as GPIO outputs and toggle them manually and verify they show up on your logic analyzer. That will ensure you're monitoring what you think you're monitoring.

 

Ensure pins are correctly initialized. We're only getting a glimpse of the wiring here.

 

After that, if the chip is powered, it should respond. Issue is probably in the details somewhere.

 

Who designed the board? That's who you should ask about slot A issues. You can't swap MISO/MOSI on STM32F4. On some other families you can. Could also be wired correctly and just mis-labeled.

If you feel a post has answered your question, please click "Accept as Solution".
MBolo.1
Associate III

Hi , for moment I'm not going to use the Slot A, my focus is to make it to communicate to STM, to achieve that I'm going to use just the Slot B for moment . I followed the steps from page 62(Chapter 10) of the ADS1299 Documentation to make the chip to work , and so far I'm at the step nr.5 and getting VCAP1 the voltage of 1.192V so theoretically the chip is initialized.

This is a piece of the code :

  //1.Set PC6  (ADC_CLKSEL) low to select the internal clock.
  	    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_6, GPIO_PIN_RESET); // Select internal clock

  	  //2. POWERING THE ADS ENABLE HIGH pin  SLOT2 (PD10=PWDN)
  	            //Set PD10 (ADC_PDWN) to high to power up the ADS.
  	   	  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_10, GPIO_PIN_SET);
  	   	//3 Toggle PC7 (ADS_RESET) to reset the ADS.
  	 // HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_7);// Assert RESET
  	HAL_GPIO_WritePin(GPIOC, GPIO_PIN_7, GPIO_PIN_RESET); // Deassert RESET
  	   	  // Allow some time for power stabilization
  	   	 HAL_Delay(50);  // Delay to allow reset
  	  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_7, GPIO_PIN_SET); // Deassert RESET
  	  //HAL_Delay(500);

and the "communication" to the chip

HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_RESET);  // Select ADS (CS2 low)
	  // Transmit read command
	  //spiStatus=HAL_SPI_GetState(&hspi2);
	  //HAL_SPI_Transmit(&hspi2, (uint8_t*)&SYS_START, 1, HAL_MAX_DELAY);
	  HAL_SPI_Transmit(&hspi2,(uint8_t*)&READ, 1, HAL_MAX_DELAY);

	  HAL_SPI_Transmit(&hspi2,(uint8_t*) &numBytes,1,HAL_MAX_DELAY);



	  // Receive the ID register content
	  HAL_SPI_Receive(&hspi2, (uint8_t*)&spi_buf, 1, HAL_MAX_DELAY);
	// HAL_SPI_TransmitReceive(&hspi2, (uint8_t *)&READ_ONLY_ID, (uint8_t *)&numBytes, 1, 100);

	  // Chip Select high
	  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_SET);  // Deselect ADS (CS2 high)

As seen in the code I tried the TransmitReceive () methide too but still no luck. Only thing that comes in my head is that my clock setting are wrong or that way how the bitts are transmited is wrong too.

I mean, you can see the signal in the logic analyzer and it looks correct. So it's probably not a code issue. CS, SCK and MOSI all behave as expected. Whatever the reason is for MISO not responding, it's not due to the signal being incorrect. Could be that MISO is not hooked up, or hooked up incorrectly, or chip is not powered correctly, or some other wiring mismatch.

If you feel a post has answered your question, please click "Accept as Solution".
QSHAO.1
ST Employee

With what shown in Analyzer, it seems you are send out data successfully by driving SCK and MOSI, the only thing is no feedback received on MISO which should be driven by ADS. so pls. check MOSI pin of STM32F4 is connected to DIN pin of ADS, and MISO pin of STM32F4 is connected to DOUT of ADS. 

below is SPI communication waveform in ADS datasheet,FYI.

QSHAO1_0-1729826329614.png

 

Hello.

I checked the continuity of lines and this is what I have for the slot 2 : (STM)MOSI--(ADS)DIN

(STM)MISO--(ADS)DOUT; (STM) SCK--(ADS) SCKL

As for the ADS powering sequence. First followed the procedure from the  ADS datasheet, then adapted the code from other people and so far I have this code :

 

 

//All inputs low
  HAL_Delay(200);
  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_7, GPIO_PIN_RESET);  // Reset low
  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_10, GPIO_PIN_RESET);  // Power Down 2 low

  // Power up ADS2 (PDWN2) and reset it
  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_10, GPIO_PIN_SET);  // Power Down 2 high (chip 2 powered up)
  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_7, GPIO_PIN_SET);  // Reset chip 2 high
  HAL_Delay(200);  // Wait for chip to stabilize

  // Reset pulse
  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_7, GPIO_PIN_RESET);  // Reset chip 2 low
  HAL_Delay(200);
  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_7, GPIO_PIN_SET);  // Reset chip 2 high

  // All other CS pins high
  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_15, GPIO_PIN_SET);  // CS1 high
  HAL_GPIO_WritePin(GPIOE, GPIO_PIN_10, GPIO_PIN_SET);  // CS3 high
  HAL_GPIO_WritePin(GPIOE, GPIO_PIN_9, GPIO_PIN_SET);   // CS4 high

  // Select ADS2 (CS2) and send SDATAC command
  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_RESET);  // CS2 low
  HAL_SPI_Transmit(&hspi2, (uint8_t*)&READ_DATA_SDATAC, 1, HAL_MAX_DELAY);
  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_SET);  // CS2 high
  HAL_Delay(1);

  // Set internal reference
  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_RESET);  // CS2 low
  uint8_t internal_reference2[] = {0x40, 0x01};  // Example command for internal reference
  HAL_SPI_Transmit(&hspi2, internal_reference2, 2, HAL_MAX_DELAY);
  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_SET);  // CS2 high

  // Read ID
  uint8_t txBuffer2[3] = {0x20, 0x00};  // READ command + ID register address
  uint8_t rxBuffer2[3] = {0};  // Buffer for response
  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_RESET);  // CS2 low
  HAL_SPI_TransmitReceive(&hspi2, txBuffer2, rxBuffer2, 3, HAL_MAX_DELAY);
  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_SET);  // CS2 high

  // Wait until SPI transfer completes
  while (HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY);

 

Also now the code sends a set of 3 bytes at the same time like in documentation

CaptureForSTMForum.JPG

 

 

 

Also today I noticed that MOSI is not going Low after data is transmitted

CaptureMOSIHIGH.JPG 

 

Also this is the set-up

 

image0.jpeg