-
-
-
If you look at the Data sheet there is an interrupt called the TC (Transmit complete) interrupt that is triggered when the last bit of the last byte has been transmitted see page attached on the TC / TXE behaviour, you would just need to check for the TC bit in the UART interupt and if a Portline was defined as TXEN then just toggle it. Do you use DMA for UART transmission? don't think this would cause an issue but you world need to ensure that the TXEN line was asserted before the TXE bit was set and the first byte was loaded into the transmit buffer.
-
This could be done in software by setting a required pin that you wanted to use for the TXEN when configuring the UART. Then before data was loaded into the UART and its FIFO this TXEN pin could be set. Then by having a simple interrupt handler for the TC (transmit complete) interrupt of the UART you could reset this TXEN pin. If the TXEN bit was not specified or was 0 when the UART was configured then GPIO pin would be toggled.
This would be nice as no timers would be required, would work no matter what the baud rate and should require very little additional code.
Note it would be could to be able to specify the state the TXEN pin should be in for Transmit, by default for a MAX485 type 8 pid device TXEN should be high for transmit, and low for recieve. In this case as soon as the UART is configured with TEXN support, the requested TXEN line should be taken low to allow RS485 reception (Which should be the default state)
-
I would like to interface one of the UART's to a Half Duplex RS485 link. Specifically this would be for Modbus RTU communication at 115200 baud. You could use an interupt handler in the TC bit of the UART to toggle a GPIO line off at the end of transmission, but would need to set this GPIO at the start of transmission. It doesn't look like the STM32 chip provides direct hardware support for toggling a TX_EN line like some chips do. Any idea's how I might go about doing this?
Also can I set non standard baud rates like 250,000 baud (DMX) and 31,250 (MIDI) for the UARTS, I'm guessing you can as they have fractional divisors for the baud rate generators.
Just thought I'd let you know about this posting "An SDK for the ESP8266 WiFi Chip"
http://hackaday.com/2014/10/25/an-sdk-for-the-esp8266-wifi-chip/