cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F446ZE SPI4 PORTE MISO Pin does not work as required or expected.

-MCR-
Associate II

I am using SPI4 PORTE pins 2,5 and 6. I have a 16 channel ADC hooked up to it. Everything functions as needed on the ADC including. Reset, Averaging setup, channels setup. I can see the MISO pin(Pin 5 PortE changes as the voltage changes. but 0 is read from the DR on the SPI peripheral.

I noticed in the data manual PORTE AF5(Alternate function 5) is assigned to two sets of pins

DS10693 Rev 10 Page 61

PORTE Pin 2 = SPI4_SCK

PORTE Pin 5 = SPI4_MISO

PORTE Pin 6 = SPI4_MOSI

and

PORTE Pin 12 = SPI4_SCK

PORTE Pin 13 = SPI4_MISO

PORTE Pin 14 = SPI4_MOSI

I used CUBEMX to setup the pins for the peripheral, and have double checked it. I use the generated SPI function HAL_SPI_TransmitReceive to get the data.

We also had this part work on two other boards, using a different SPI port.

Do I have to use PORTE pin 13 for the MISO? Why does PORTE Pin 5 not work as advertised?

 

1 ACCEPTED SOLUTION

Accepted Solutions

Okay, I got it...The AF Register is at 3...I have to dig into why that is. 

Thank you everyone for your help.

View solution in original post

9 REPLIES 9

PE5 AF5 and PE13 AF5 should both be viable in a one or the other sense.

What board are we talking about? Make sure there isn't a pin level conflict, that the pin from the IC gets to the point which you are probing. Check schematic, check continuity, check for any solder bridge or resistors in the path.

Going to need to see more of the board design and code to be able to better understand what's going on.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

As I said before I can electrically see the data at Pin5 It definitely changes as the voltage changes. I can see the clock, and the MOSI pin 6 works as the ADC is setup properly. So the only thing I can surmise is the pin is not connected to the pin. I checked the project code for any PORTE references and everything is as expected without overrides of the pin in question.

CUBE MX generated the code

/**SPI4 GPIO Configuration

PE2 ------> SPI4_SCK

PE5 ------> SPI4_MISO

PE6 ------> SPI4_MOSI

*/

GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_5|GPIO_PIN_6;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF5_SPI4;

HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

 

This is a in house circuit board.

I'm not aware of any outstanding issue with the F4 parts and documentation, they've been sold for a decade.

You might want to open an online support request via the OLS, or discuss with your local FAE

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

> I can see the MISO pin(Pin 5 PortE changes as the voltage changes

Did you measure *directly* at the physical pin?

Read out and check/post content of SPI and GPIOE registers.

Another possible exercise is to manually bit-bang the SPI.

JW

Yes I measured it directly on the processor pin.

Here are the register settings

PI4 Registers
==============
CR1 = 0x00000354
CR2 = 0x00000000
CCRCPR = 0x00000007
I2SCFGR = 0x00000000
I2SPR = 0x00000000
RXCRC = 0x00000000
SR = 0x00000002
TXCRC = 0x00000000

PORTE Registers
===============
AFR = 0x40021020
BSRR = 0x00000000
IDR = 0x00003A60
LCKR = 0x00000000
MODER = 0x00492920
ODR = 0x00000800
OSPEEDR = 0x00823230
OTYPER = 0x00000000
PUDR = 0xAA208080

 

 

Okay, I got it...The AF Register is at 3...I have to dig into why that is. 

Thank you everyone for your help.

The AFR is spread over 2 32-bit registers ie AFR[0..1] or AFRL/AFRH

The first dealing with Pin#0..7 the other with Pin#8..15

16x 4-bit -> 64-bits

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

AF3 for PE5 is TIM9_CH1, so you probably set that somewhere, too.

If you don't know where, set a data breakpoint (aka watchpoint) on GPIOE_AFR[0] to find out where is it modified.

JW