2024-10-01 08:28 AM
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?
Solved! Go to Solution.
2024-10-01 11:15 AM
Okay, I got it...The AF Register is at 3...I have to dig into why that is.
Thank you everyone for your help.
2024-10-01 08:48 AM
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.
2024-10-01 08:54 AM
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);
2024-10-01 09:00 AM
This is a in house circuit board.
2024-10-01 09:09 AM
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
2024-10-01 10:26 AM - edited 2024-10-01 10:31 AM
> 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
2024-10-01 11:07 AM
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
2024-10-01 11:15 AM
Okay, I got it...The AF Register is at 3...I have to dig into why that is.
Thank you everyone for your help.
2024-10-01 12:17 PM
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
2024-10-02 01:26 AM
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