Skip to content

Increase performance of UART RX. #139

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

Merged
merged 1 commit into from
Mar 19, 2020
Merged

Increase performance of UART RX. #139

merged 1 commit into from
Mar 19, 2020

Conversation

nseidle
Copy link
Member

@nseidle nseidle commented Mar 18, 2020

This PR

  • Increases the UART buffers from 256 * 4 (TX/RX for UART0 and UART1) to 4096 * 4
  • Removes the loop within the RX ISR
  • These changes allow Artemis to receive full speed 460800bps without dropping bytes

We are only doing single byte reads from the UART FIFO. By calling am_hal_uart_transfer multiple times it increases the ISR time.

Original timing:
image

Timing after this PR:

image

You can see the ISR becomes shorter and more repetitive.

FWIW - With burst mode turned on, ISR drops even more to 8.5us so 921600bps may be possible.

For reference:

  • How big is RX FIFO within HAL? 32 bytes
  • Is there a 'nearly full' interrupt for the RX FIFO? No
  • We could check the RX FIFO empty bit in the ISR in a loop but this is basically skirting the HAL layer. I've attempted this without much luck.
  • We could increase the ISR priority level but we haven't done this for any ISRs in the core, yet, so I'm not sure if we want to.

This PR attempts to strike a balance between RAM footprint (what's and extra 15k between friends?) and increase serial performance.

@nseidle nseidle changed the title Increase buffers to 4k. Remove loop from RX ISR. Increase performance of UART RX. Mar 18, 2020
@oclyke
Copy link
Contributor

oclyke commented Mar 19, 2020

Cool - where previously the ISR allowed for possibly catching more than one byte per interrupt (with the do while loop) we now expect to read just one byte each time. This reduces execution time significantly because there is not a wasted HAL call that is used to show when no more data is available in the HAL buffers. Looks good to me!

@oclyke oclyke merged commit c7b5cc7 into master Mar 19, 2020
@oclyke oclyke deleted the decrease_RX_ISR_Overhead branch March 19, 2020 20:24
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