cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with GPIO in STM32F100 discovery card

LMI2
Lead
Posted on June 28, 2015 at 02:12

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

7 REPLIES 7
Posted on June 28, 2015 at 03:32

HAL_GPIO_WritePin(GPIOC, 0x09,1 );

Are you sure it's an index, and not a bit vector?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
LMI2
Lead
Posted on June 28, 2015 at 18:35

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?
LMI2
Lead
Posted on June 28, 2015 at 21:41

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.

Posted on June 29, 2015 at 01:14

Your initial code example is for an L1xx device, not an F1xx device, are you sure you're not mixing up targets?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
LMI2
Lead
Posted on June 29, 2015 at 11:58

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?

LMI2
Lead
Posted on June 29, 2015 at 17:53

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?

Posted on June 29, 2015 at 18:56

I still wonder what kind Discovery board is it, too old to be supported by the Cube sw?

Sounds like the original 

http://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.

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