On 2022-03-28,
anti...@math.uni.wroc.pl <
anti...@math.uni.wroc.pl> wrote:
> pozz <
pozz...@gmail.com> wrote:
>>
>> Some years ago, I read the idea to use the same UART peripheral as a
>> "timer" to have a short delay in the reply. It is sufficient to send
>> some dummy bytes, but not really.
>
> Well, if there is availible hardware timer, than arguably _not_
> using it is a waste. If there is shortage of timers, then
> multi-purposing single timer looks like better solution.
>
> AFAICS main disadvantage of using UART is lack of portablity
> and flexibility. You are tied to specific behaviour of UART,
> changing to different mode (like enabling FIFO) can break
> your code. And you only get multiple of character transmit
> time as delay.
I'm a bit late into this discussion but this was a standard trick
in the days of serial terminals - the first glass terminals used
either discrete logic or very primitive CPUs and thus operations
such as scrolling or even cursor movement would take longer to
execute than would be implied by the baud rate. Look up terminal
padding - where NULL bytes were inserted after certain control
codes to allow the terminal to process what it had just been sent.
Portability was in fact on the main advantages - the code knew the
bauda rate and how long processing took on a given terminal so
could compute the padding the add without external dependencies.
Important at the ttime since UNIX (in particular) didn't provide
convenient sub-second delays at first. It also benefitted from
the fact it a NULL byte had known behaviour on most terminals -
i.e. a no-op.
On an embedded device you'd have to weigh up those benefits against
the closer to the hardware nature of firmware - i.e. you have less
intervening software in the way isolating you from the hardware.
Personally I wouldn't like to say what's best except in relation
to the circumstances - like any delay you might be looking at a
timer and interrupt, a delay loop or even a couple of no-ops (or
shuffling of tasks) to enforce however long is needed.
--
Andrew Smallshaw
and...@sdf.org