2020-04-23 07:49 AM
Hi. i have some problem when verifying the board composed of STM32F030RCT7 with Keil IDE (MDK ARM). I still don't know much about FW, so I ask a few stupid questions.
Problem 1. I am basically setting the project through STM32CubeMX. I checked that the option of [Set All free pins as analog] in the Code Generator of the Project Manager reduces the power consumption. I checked the [Debug Serial Wire] option. With these two settings, I found that the power saving option is checked and debugged as desired, but I don't understand one thing. In the Keil project setting, the reset after flash option is used among the Debugger options, and the timer that should be output every 1 second after uploading the firmware is output at a speed faster than 1 second. If you press the button connected to the RST, the output is normally every 1 second from then on. I am wondering why this is happening.
Problem 2. Currently, 4 ADCs and 6 GPIO Outs are to be used. ADC tries to use 12 ~ 15 as DMA, GPIO uses PA 9 ~ 12, PB2, PB4. At this time, if one of the GPIO pins is HAL_GPIO_WritePin (SET), the HAL_ADC_ConvCpltCallback function is called like crazy. if (hadc-> Instance == ADC1) is not filtered by this code. Could I have misinterpreted the datasheet when the pins are affecting each other? If you don't use GPIO, it works as intended.
// HAL_GPIO_WritePin(STATUS_LED_GPIO_Port, STATUS_LED_Pin, GPIO_PIN_SET); // if i active this code, call HAL_ADC_ConvCpltCallback serveral time.
int main(){
while (1)
{
if(isReadyReadAdc)
{
HAL_ADC_Start_DMA(&hadc, (uint32_t *)adc_buffer, ADC_DMA_BUF_LEN);
isReadyReadAdc = FALSE;
}
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
}
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
if(hadc->Instance == ADC1)
{
HAL_ADC_Stop_DMA(hadc);
isReadyReadAdc = TRUE;
printf("finish read ADC\r\n");
}
}
Problem 3. Three UART circuits are currently configured. UART1, UART3, UART4. Mirroring function is implemented in Interrupt mode through UART1. However, in the case of UART3 and UART4, looking at STM32CubeMX to enable the Interrupt function, there was an option called "UART3 to UART6 global interrupt" where the Intterupt option should be. I tried to ignore it, the callback function was not called because it implements mirroring function like UART1. So, how to implement mirroring function for UART3 and UART4?
Thanks for reading the long text.
Solved! Go to Solution.
2020-04-23 09:16 AM
> Problem 2
Seems unlikely that using a GPIO pin is causing ADC to misbehave. They should be independent.
> Problem 3
USART3 through USART6 do not have a dedicated IRQ. They all share the same interrupt. So enable it (don't ignore it) and read USART status bits within the interrupt to determine which peripheral caused it. HAL does all of this for you.
IRQs have special names that are referred to in the vector table.
2020-04-23 09:16 AM
> Problem 2
Seems unlikely that using a GPIO pin is causing ADC to misbehave. They should be independent.
> Problem 3
USART3 through USART6 do not have a dedicated IRQ. They all share the same interrupt. So enable it (don't ignore it) and read USART status bits within the interrupt to determine which peripheral caused it. HAL does all of this for you.
IRQs have special names that are referred to in the vector table.
2020-04-23 10:02 AM
Problem 2
> After many misunderstandings, became independent. I am not sure exactly what was the problem.
Problem 3
> I misunderstood the sentence. Because IRQ is not independent, used "to". Thank you.
2020-04-23 10:42 AM
Problem 3
> coding like below. but dosen't call callback function when send to UART3...
static void MX_USART3_UART_Init(void)
{
/* USER CODE BEGIN USART3_Init 0 */
/* USER CODE END USART3_Init 0 */
/* USER CODE BEGIN USART3_Init 1 */
/* USER CODE END USART3_Init 1 */
huart3.Instance = USART3;
huart3.Init.BaudRate = 9600;
huart3.Init.WordLength = UART_WORDLENGTH_8B;
huart3.Init.StopBits = UART_STOPBITS_1;
huart3.Init.Parity = UART_PARITY_NONE;
huart3.Init.Mode = UART_MODE_TX_RX;
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart3.Init.OverSampling = UART_OVERSAMPLING_16;
huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart3) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART3_Init 2 */
HAL_UART_Receive_IT(&huart3, (uint8_t *) uart3RxBuffer, USART3_RX_BUF_LEN);
/* USER CODE END USART3_Init 2 */
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
printf("UART CALLBACK\rn");
if(huart->Instance == DEBUG_UART_INSTANCE)
{
// HAL_UART_Transmit(DEBUG_UART, (uint8_t *) DEBUG_BUF, DEBUG_RX_BUF_LEN, DEBUG_TX_TIMEOUT);
// HAL_UART_Transmit(&huart1, (uint8_t *) DEBUG_BUF, DEBUG_RX_BUF_LEN, USART3_TX_TIMEOUT);
HAL_UART_Transmit(&huart3, (uint8_t *) DEBUG_BUF, DEBUG_RX_BUF_LEN, USART3_TX_TIMEOUT);
HAL_UART_Transmit(&huart4, (uint8_t *) DEBUG_BUF, DEBUG_RX_BUF_LEN, USART4_TX_TIMEOUT);
HAL_UART_Receive_IT(DEBUG_UART, (uint8_t *) DEBUG_BUF, DEBUG_RX_BUF_LEN);
}
else
{
HAL_UART_Transmit(DEBUG_UART, (uint8_t *) DEBUG_BUF, DEBUG_RX_BUF_LEN, DEBUG_TX_TIMEOUT);
HAL_UART_Transmit(&huart3, (uint8_t *) uart3RxBuffer, USART3_RX_BUF_LEN, USART3_TX_TIMEOUT);
HAL_UART_Receive_IT(&huart3, (uint8_t *) uart3RxBuffer, USART3_RX_BUF_LEN);
}
}
2020-04-23 07:55 PM
I modified the code a little, but it works well because I pulled down the RX line. Was this a problem?
2020-04-24 03:09 AM
I think, I was have a problem on usb hub...