cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, I'm interfacing Nucleo-L476RG with a UART Device. If I power off that devices, my Nucleo code freeze and I need to manually reset it. I need to power-on and to power-off the device and the Nucleo must continue to works.

FManc.1
Associate II

Nucleo send through UART4 and receive with DMA from devices. Then Nucleo send to PC via USART2 for debugging. In UART4 there is Idle Line detect for receiving unknown length of data.

This is my code:

        MX_GPIO_Init();
	MX_DMA_Init();
	MX_UART4_Init();
	MX_USART2_UART_Init();
 
        HAL_UART_Receive_DMA(&huart4, (uint8_t*) dma_rx_buf, DMA_BUF_SIZE);
        //HAL_UART_RxCpltCallback put my data from circular buffer "dma_rx_buf" to "data"
 
	/* Disable Half Completed and Completed Transmission Interrupt */
	__HAL_DMA_DISABLE_IT(huart4.hdmarx, DMA_IT_HT);
	__HAL_DMA_DISABLE_IT(huart4.hdmarx, DMA_IT_TC);
 
	DEVICE_Init(&huart4);
	DEVICE_Set_Debug_UART(&huart2);
 
	uint32_t now = HAL_GetTick();
	uint32_t last = now;
 
	while (1) {
                        if (dma_uart_rx.data_rcv_flg) {
			dma_uart_rx.data_rcv_flg = 0;
			HAL_UART_Transmit(&huart2, data, strlen((char*) data), 50);
			DEVICE_Receive(data);
		}
		now = HAL_GetTick();
		if (now - last > 10000) {
			HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
			char cmd[11] = { '2', '0', '0', '7', '0', '1, 'H', 'e', 'l', 'l', 'o' };
			HAL_UART_Transmit(&huart4, (uint8_t*) cmd, 11, HAL_MAX_DELAY);
			last = now;
		}

If the device is power-on and connected to UART4, all works.

If i power-off device while my code is running, on UART2 I start to receive what I send to UASRT4. I can't explain this.

If I re-power-on the device, my MCU freeze and I have to restart manually.

If the MCU is running and I power-on the device, MCU freeze.

If the device is not connected to UART4, code freeze in HAL_UART_Receive_DMA(...)

I need to power-on and power-off my device in some parts of code. For now I'm switching it on/off manually but later I have to do this programmatically using a GPIO.

Why I get this behaviour?

0 REPLIES 0