Configure SPI on stm32f205
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-31 6:55 AM
Hello!
How can I configure only the MISO pin in the mode falling edge triggered interrupt input? It's not possible to do it on CubeMX. I tried to change the spi.c file like follows:
/**SPI3 GPIO Configuration
PA15 ------> SPI3_NSS
PC10 ------> SPI3_SCK
PC11 ------> SPI3_MISO
PC12 ------> SPI3_MOSI
*/
GPIO_InitStruct.Pin = GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12;
GPIO_InitStruct.Mode = I replaced GPIO_MODE_AF_PP; by GPIO_MODE_AF_PP|GPIO_MODE_IT_FALLING|GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
But it doesn't work. Any help, please?
Solved! Go to Solution.
- Labels:
-
SPI
-
STM32F2 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-27 5:32 AM
thank you all for your help so far. I realized that only setting on Cube a pin as Alternate Function Push Pull is enough to allow you to use this pin as falling edge triggered interrupt input (as this was need for the ADC ads1118). The problem was actually with the spi3 configuration on Cube: I misconfigured the CPAH. This was the key to solve the issue!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-31 9:49 AM
I don't think it's possible within the HAL framework. But you can do it by editing registers directly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-01 4:32 AM
I got your point. And could you give an example for my case, how it should be done?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-04 7:16 PM
I suggest to configure the Exti interrupt for miso and spi without miso in cube mx, then, after mx init, manually reactivate miso as spi alternate signal. Hack will work. EXTI on alternate function pin works fine even if the HAL didn't foresaw users needing this confuguration and CubeMX based apparently on HAL and not the reference manual.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-05 11:07 AM
Hello @S.Ma​ let me see if I got you point: you mean activate SPI on CubeMX, then change the MISO pin configuration to GPIO_EXTIx, then after MX init change manually back MISO pin configuration to alternate function?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-05 1:15 PM
You got it, CubeMX is a static HW configuration, you can override it manually.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-07 1:59 PM
@S.Ma​ can I just reconfigure it inside the functions HAL_SPI_MspInit and HAL_SPI_MspDeInit ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-07 10:56 PM
Well, run your code with debugger and check if your code insertion work by looking at the gpio and exti registere.... not specialist of hal intricacies.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-08 2:04 AM
the program gets stuck here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-26 8:43 PM
Did you create the exti interrupt handler function? If this looks difficult to you, get a files compare text viewer, generate a simple concisr project for spi and exti, look at both anf try to merge. Exti and spi are decorrelated function. You decide when each one has to be enabled
