STM32F4 how to change pins from USART to GPIO and back to USART again
// Init the GPIO
GPIO_InitTypeDef GPIO_InitStruct = {0};
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
GPIO_InitStruct.Pin = GPIO_PIN_2;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
// Set the pin low and wait
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2 , GPIO_PIN_RESET);
DWT_Delay_us (100);
// set the pin high and wait
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2 , GPIO_PIN_SET);
DWT_Delay_us (12);
// turn off GPIO - should go back to USART
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
// Send DMX Data
RS485_TX(9); // Send the start plus 8 data bytesHello. I am trying to setup a USART transmitter which has some specific timing requirements for the signal lines before transmitting the data (it's for a DMX lighting controller). I need to have the TX pin idle high, then go low for 100uS, then high again for 12uS, and then send the serial data after that.
I have no trouble either sending the serial data, or doing the high/low timing beforehand. But I can't seem to find a way to do both. The USART is initially setup (Using STMCube32 and Freertos), and works fine, but not if I init the pins as GPIO do the high.low timing then deinit the pins again. I read that I shouldn't need to deinit / reinit the USART itself - which I have tried too.
Any ideas? Using STM32F401VCT6.
Cheers - Matt
