cancel
Showing results for 
Search instead for 
Did you mean: 

Found three bugs with latest STM32 version 1.24.2 - Need to press the reset button at start

DMårt
Lead

Hi!

I found three bugs I want to report. It's about the STM32 version 1.24.2. I'm using Nucleo STM32F401RE board.

First bug is that MX_DMA_Init() need to be before MX_USART2_UART_Init() like this:

/* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_USART2_UART_Init();
  MX_ADC1_Init();
  MX_TIM1_Init();
  MX_TIM2_Init();
  /* USER CODE BEGIN 2 */

Second bug is that if you place HAL_GPIO_WritePin inside the function HAL_UART_RxCpltCallback, you need to manually turn the GPIO pin FALSE, before you can even use it.

Like this:

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
 
	// Check if we are going to ONLY set PWM's(0) or set digitals(1). Last RXData have the send state element
	uint8_t send_state = RXData[sizeof(RXData) / sizeof(RXData[0]) - 1];
	if (send_state == 0) {
		// Set PWM counters period by convert short -> byte
		htim1.Instance->CCR1 = (uint32_t) ((RXData[0] << 8) | RXData[1]);
		htim1.Instance->CCR2 = (uint32_t) ((RXData[2] << 8) | RXData[3]);
		htim1.Instance->CCR3 = (uint32_t) ((RXData[4] << 8) | RXData[5]);
		htim1.Instance->CCR4 = (uint32_t) ((RXData[6] << 8) | RXData[7]);
		htim2.Instance->CCR1 = (uint32_t) ((RXData[8] << 8) | RXData[9]);
		htim2.Instance->CCR2 = (uint32_t) ((RXData[10] << 8) | RXData[11]);
	} else if (send_state == 1) {
 
		// This is for fixing a bug - It need to be put here due to STM32 version 1.24.2
		HAL_GPIO_WritePin(Digital0_GPIO_Port, Digital0_Pin, GPIO_PIN_RESET);
 
		// For digitals only
		HAL_GPIO_WritePin(Digital0_GPIO_Port, Digital0_Pin, RXData[12]);
		HAL_GPIO_WritePin(Digital1_GPIO_Port, Digital1_Pin, RXData[13]);
		HAL_GPIO_WritePin(Digital2_GPIO_Port, Digital2_Pin, RXData[14]);
		HAL_GPIO_WritePin(Digital3_GPIO_Port, Digital3_Pin, RXData[15]);
		HAL_GPIO_WritePin(Digital4_GPIO_Port, Digital4_Pin, RXData[16]);
		HAL_GPIO_WritePin(Digital5_GPIO_Port, Digital5_Pin, RXData[17]);
		HAL_GPIO_WritePin(Digital6_GPIO_Port, Digital6_Pin, RXData[18]);
		HAL_GPIO_WritePin(Digital7_GPIO_Port, Digital7_Pin, RXData[19]);
		HAL_GPIO_WritePin(Digital8_GPIO_Port, Digital8_Pin, RXData[20]);
		HAL_GPIO_WritePin(Digital9_GPIO_Port, Digital9_Pin, RXData[21]);
		HAL_GPIO_WritePin(Digital10_GPIO_Port, Digital10_Pin, RXData[22]);
		HAL_GPIO_WritePin(Digital11_GPIO_Port, Digital11_Pin, RXData[23]);
		HAL_GPIO_WritePin(Digital12_GPIO_Port, Digital12_Pin, RXData[24]);
		HAL_GPIO_WritePin(Digital13_GPIO_Port, Digital13_Pin, RXData[25]);
		HAL_GPIO_WritePin(Digital14_GPIO_Port, Digital14_Pin, RXData[26]);
		HAL_GPIO_WritePin(Digital15_GPIO_Port, Digital15_Pin, RXData[27]);
		HAL_GPIO_WritePin(Digital16_GPIO_Port, Digital16_Pin, RXData[28]);
		HAL_GPIO_WritePin(Digital17_GPIO_Port, Digital17_Pin, RXData[29]);
		HAL_GPIO_WritePin(Digital18_GPIO_Port, Digital18_Pin, RXData[30]);
		HAL_GPIO_WritePin(Digital19_GPIO_Port, Digital19_Pin, RXData[31]);
		HAL_GPIO_WritePin(Digital20_GPIO_Port, Digital20_Pin, RXData[32]);
		HAL_GPIO_WritePin(Digital21_GPIO_Port, Digital21_Pin, RXData[33]);
		HAL_GPIO_WritePin(Digital22_GPIO_Port, Digital22_Pin, RXData[34]);
		HAL_GPIO_WritePin(Digital23_GPIO_Port, Digital23_Pin, RXData[35]);
		HAL_GPIO_WritePin(Digital24_GPIO_Port, Digital24_Pin, RXData[36]);
		HAL_GPIO_WritePin(Digital25_GPIO_Port, Digital25_Pin, RXData[37]);
		HAL_GPIO_WritePin(Digital26_GPIO_Port, Digital26_Pin, RXData[38]);
		HAL_GPIO_WritePin(Digital27_GPIO_Port, Digital27_Pin, RXData[39]);
		// Last element is the send state, position 40
	}
 
	// Convert ADC values to
	TXData[0] = (uint8_t) (ADCValues[0] >> 8);
	TXData[1] = (uint8_t) (ADCValues[0] & 0xFF);
	TXData[2] = (uint8_t) (ADCValues[1] >> 8);
	TXData[3] = (uint8_t) (ADCValues[1] & 0xFF);
	TXData[4] = (uint8_t) (ADCValues[2] >> 8);
	TXData[5] = (uint8_t) (ADCValues[2] & 0xFF);
	TXData[6] = (uint8_t) (ADCValues[3] >> 8);
	TXData[7] = (uint8_t) (ADCValues[3] & 0xFF);
	TXData[8] = (uint8_t) (ADCValues[4] >> 8);
	TXData[9] = (uint8_t) (ADCValues[4] & 0xFF);
	TXData[10] = (uint8_t) (ADCValues[5] >> 8);
	TXData[11] = (uint8_t) (ADCValues[5] & 0xFF);
 
	// Send data to JLoggerServer in about 5 milliseconds
	HAL_UART_Transmit(&huart2, TXData, sizeof(TXData) / sizeof(TXData[0]), 5);
 
	// Listen for a new receive
	HAL_UART_Receive_DMA(&huart2, RXData, sizeof(RXData) / sizeof(RXData[0]));
 
}

The third bug is that I need to reset the STM32 by pressing the black button on the Nucleo board, after I have turn on the power to the STM32 Nucleo board. Else, the UART won't work for me.

Here is my complete code:

 https://pastebin.com/qashaiLg

STM32MP151AAC3 custom board with STM32-OS as operating system: https://github.com/DanielMartensson/STM32-Computer
1 REPLY 1
DMårt
Lead

By the way!

Is there a way to select 1.24.0 in STMCubeIDE​ after a project is created?

STM32MP151AAC3 custom board with STM32-OS as operating system: https://github.com/DanielMartensson/STM32-Computer