Problem with GPIO in STM32F100 discovery card
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-06-27 5:12 PM
I have tried to test GPIO programming with CubeMX and the F100 discovery card. But outputs do not change.
I have a project directly from Cube, it has only IO which are used in Discovery card, other outputs don't work either. I only added HAL_GPIO_WritePin(GPIOC, 0x09,1 ); in this project but other instructions do not work either. The card works, because ready made demos work. But I would like to use projects from Cube for now.#include ''stm32l1xx_hal.h''
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
while (1)
{
/* USER CODE END WHILE */
HAL_GPIO_WritePin(GPIOC, 0x09,1 );
}
/* USER CODE END 3 */
}
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
__PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = 16;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
__SYSCFG_CLK_ENABLE();
}
void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* GPIO Ports Clock Enable */
__GPIOC_CLK_ENABLE();
__GPIOH_CLK_ENABLE();
__GPIOA_CLK_ENABLE();
__GPIOB_CLK_ENABLE();
/*Configure GPIO pin : PA0 */
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pins : PC8 PC9 */
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_VERY_LOW;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
#ifdef USE_FULL_ASSERT
void assert_failed(uint8_t* file, uint32_t line)
{
}
#endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-06-27 6:32 PM
HAL_GPIO_WritePin(GPIOC, 0x09,1 );
Are you sure it's an index, and not a bit vector?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-06-28 9:35 AM
I changed the code a little
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_9 , GPIO_PIN_SET );
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8 , GPIO_PIN_SET );
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_All, GPIO_PIN_SET );
The compiler gives no more warnings, but the leds are off. I turned on the B port too, no improvment.
The card still works, I tried the demo blink code and it works.
By the way, I found this. Could these be related?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-06-28 12:41 PM
Yes, There is a problem with STM32F100 discovery card and F100RB cpu and projects from Cube.
I have a 207 board also. The same SW which did not work in F100, works in F207.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-06-28 4:14 PM
Your initial code example is for an L1xx device, not an F1xx device, are you sure you're not mixing up targets?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-06-29 2:58 AM
You are right, but there was no Discovery board with 32F100RB cpu on the list. There is a code on the board MB913C. What is the correct one then?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-06-29 8:53 AM
The boards works as a plain CPU board now. Except that it loses the connection everytime after programming. This board is simple, so it does not matter is it a Discovery board or not.
I still wonder what kind Discovery board is it, too old to be supported by the Cube sw?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-06-29 9:56 AM
I still wonder what kind Discovery board is it, too old to be supported by the Cube sw?
Sounds like the originalhttp://www.st.com/web/en/catalog/tools/PF250863
board, using the F100 ''Value Line'' parts. I'm sure one could plug in specific board details, pin lists or whatever, into Cube. I'm not a HAL/Cube user, and not providing support for such.Up vote any posts that you find helpful, it shows what's working..
