2019-07-18 05:28 AM
// 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 bytes
Hello. 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
2019-07-18 05:58 AM
Would probably just switch state in GPIOA->MODER, check RM0090
2019-07-18 04:26 PM
Thanks Clive. I've had a quick look but I don't have the hardware with me right now to check. Will try a bit later today. Cheers.
2019-07-19 07:03 AM
Hi Clive. Didn't work at first, but more reading and more suck it and see trying and have it all working now. Thanks for the guidance with the MODER command (never seen that register before - always been handled by STMCube32 setup). Cheers again - Matt
2023-06-23 11:40 AM
Hi Matt,
I'm looking to do the same thing. Can you provide any guidance about how you accomplished the solution.
Thanks,
Mike
2023-06-24 12:08 AM
Don't hijack others threads. Start your own, stating the STM32 and hardware you are using, and the problem you came across. You can link to this thread if you think it's relevant.
JW