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

display: Interrupt driven ADC sampling for the touch screen #3

Open
wants to merge 5 commits into
base: devel
Choose a base branch
from

Conversation

sebastianriese
Copy link

Wait for interrupt in the main loop and make the ADC-sampling of the touch screen interrupt driven.

This could probably still be improved (e.g. by moving all the post processing to events to the interrupt handlers.

It is not entirely clear whether doing the touch sampling with interrupts is worth it – the ADC is quite fast (about 130 CPU clocks / 2.7µs for a conversion) and while a conversion is in process the communication interrupts will still work. So waiting for the three required conversions in the main loop every 50ms may be the better solution (this takes less time than transferring a single byte over the UART at 115200 baud). – So perhaps these changes should be abandoned, but the main-loop should definitely wait for interrupts (it would be awoken at least every millisecond by the systick interrupt).

This includes #2.

* The code is built with -Werror and newer gccs warn on implicit
  fallthrough with -Wall -Wextra, so the build failed.
* The build failed with linker errors with gcc 8.3 (the inline
  functions could not be linked against).

* The inline annotation were removed accordingly from functions
  that are linked, while those that are only used within one
  compilation unit were marked static inline instead.
* make -B did not work, because ln -s failed on existing links –
  fixed by using -f.
* Make the main loop non busy (use wfi instead).

* Make the touch sampling interrupt driven.

* Note: When starting with BURST_SWMODE there seem to be no ADC ready
  interrupts, so we use HWSCANMODE although we only want to sample once
  and disable the ADC in the interrupt handler.

* Open question: Is there a point in not just sampling the touch screen
  in the main loop every 50ms and have the main loop wfi and be awoken
  by the systick interrupt (the ADC is pretty quick, 11 clocks of the ADC
  clock, which is 4MHz, so just 132 CPU clocks, and less than even
  a signle bit over the UART at 115200 baud). It may well be that the
  interrupt driven method burns more cycles while only marginally
  improving responsiveness (if at all).
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.

1 participant