Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F051 serial telemetry improvements: #174

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Vuk-SFL
Copy link

@Vuk-SFL Vuk-SFL commented Feb 13, 2025

USART Tx channel disabled on TC interrupt once all bytes are transferred.

Inspired by reference manual note on how to use DMA and UART for TX transfers.

https://www.st.com/resource/en/reference_manual/rm0091-stm32f0x1stm32f0x2stm32f0x8-advanced-armbased-32bit-mcus-stmicroelectronics.pdf

Section 27.5.15: USART continuous communication in DMA mode

In transmission mode, once the DMA has written all the data to be transmitted (the TCIF flag
is set in the DMA_ISR register), the TC flag can be monitored to make sure that the USART
communication is complete. This is required to avoid corrupting the last transmission before
disabling the USART or entering Stop mode. Software must wait until TC=1. The TC flag
remains cleared during all data transfers and it is set by hardware at the end of transmission
of the last frame.

USART transmission using DMA

- USART Tx channel disabled on TC interrupt once all bytes are transfered
@AlkaMotors
Copy link
Collaborator

I would prefer to get rid of the interrupt all together. See my response to your issue about this.

@AlkaMotors
Copy link
Collaborator

AlkaMotors commented Feb 13, 2025

So if we disable all interrupts and just change the telemetry function to this :
void send_telem_DMA(uint8_t bytes) { // set data length and enable channel to start transfer LL_USART_SetTransferDirection(USART1, LL_USART_DIRECTION_TX); LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_2); LL_DMA_SetDataLength(DMA1, LL_DMA_CHANNEL_2, bytes); LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_2); LL_USART_SetTransferDirection(USART1, LL_USART_DIRECTION_RX); }

Then we don't need to rely on any interrupt and the line is reset each time. The code size and memory is reduced as well.

The TE and RE registers can both be set to 1 and the serial is still transmitted but the line stays in push_pull mode for the stm32. Setting RE = 1 and TE= 0 right after enabling the dma channel the entire packet is still send but the line just goes back to open drain after.

Also to note the ISR for both dma and usart are not affected by the state of TE and RE. The less interrupts we have the better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants