cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding SPI MISO CPOL in custom board with ATWINC1500

JMart.5
Associate II

Hello,

I hope this post is in the right place.

I've been trying for a while to integrate an ATWINC1500-MR210BP module in my custom board with a STM32L151VeT6. Project is done with STM32CubeMX and later with STM32Cube IDE. For debugging purposes I am only trying a simple code, sending a command with SPI and checking that response is the good one.

The problem is that I am not getting the right SPI response in my custom board but when I use a NUCLEO-L152 board with a ATWINC1500 (same one) module I have the correct response.

SPI config is the following : CPOL = 0, CPHA = 0, 8bits, MSB First, 1 MBit/s (using MSI RC with prescaler 2). This settings were made according to the module data sheet p. 21 https://ww1.microchip.com/downloads/en/DeviceDoc/70005304D.pdf

Code in main.c is the same for my custom board and for the Nucleo except for the pin numbers for CS, RST and Enable :

HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_SET); //ENABLE
     HAL_Delay(10);
     HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET); //RESET
     HAL_Delay(10);
 
     uint8_t address = 0x01;
     TxDataAcc[0] = 0xC4;
     TxDataAcc[1] = address >> 8;
     TxDataAcc[1] |= (1 << 7);
     TxDataAcc[2] |= address;
     TxDataAcc[3] = 0x00;
 
     HAL_GPIO_WritePin(GPIOC, GPIO_PIN_6, GPIO_PIN_RESET); //CHIP SELECT
 
     HAL_SPI_Transmit(&hspi3, TxDataAcc , 4 , 10);
     HAL_SPI_Receive(&hspi3, RxDataAcc , 6 , 10);
 
     HAL_GPIO_WritePin(GPIOC, GPIO_PIN_6, GPIO_PIN_SET); //CHIP SELECT

This SPI message is the same as p121 : https://ww1.microchip.com/downloads/en/DeviceDoc/ATWINC15x0-Wi-Fi-Network-Controller-Software-Design-Guide-DS00002389D.pdf

To wake up the chip the MCU sends : 0xC4 0x80 0x01 0x00

I get the following responses :

NUCLEO+Module(alone) : 0x00 0xC4 0x00 0xF3 0x01 0x00 (what it should be)

ATWINC in my custom board : 0x01 0x88 0x06 0x00 0x00 0x00

I checked the signal in my oscilloscope.

In both cases the MCU is transmitting correctly in the MOSI line.

I found what I think is a problem in the MSIO line in my custom board :

0693W000007BK9sQAG.pngLooks that MISO line is shifting when clocks idles back to 0. Like there is some kind of delay. The slave is listening ok in the MOSI line, therefore sending data but the slave response gets somehow delayed. I guess the problem is somewhere in my board.

And just for you info, I have the same behavior with another custom board and even in another SPI. ATWINC uses SPI3.

Do you have any recommendations ? Where should I look (soft, hard)? I am really desperate, I do not know even where to look now.. All suggestion are welcome.

Thanks for your help.

JPM

1 REPLY 1

Hello

>>This SPI message is the same as p121

This is not the same

In p121 CS pin is pulled high between tranmission and response but the code transmits and receives under the same CS pulse