UART Pass-Through

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ToVa_285016
Level 5
Level 5
100 replies posted 50 replies posted 50 questions asked

 Hi,

   

I have an application where an event will trigger the need to generate UART data, and transmit it, but if the event is not present, the UART component should act as a pass through for data, where any data in is automatically transmitted right back out without needing to look at it or modify it.  

   

What is the simplest way to do this?  Can I disable the ISRs for my own generation and transmission and somehow 'hardwire' the pins through code?

   

Thank you as usual for your help.

   

Tom

0 Likes
5 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Since it is not advisable to handle a slow device within an interrupt handler it would be advisable to set a global flag (declared as volatile!) which is checked for in the main-loop. When flag is set, transfer the required data, reset the flag and return to the echo-mode.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Since it is not advisable to handle a slow device within an interrupt handler......

   

 

   

A "slow" device is not a problem for an ISR, generally speaking it is a fast device

   

that challenges ISRs, like fast com, display refresh, etc..

   

 

   

You could use simple gating, mux, to tie Rx and Tx together to bypass internal

   

processing, and it would save you MIPs. You should coinsider using a synch

   

approach to the bypass, eg. when UART finishes a char transmit and there is

   

a pending request to bypass, then switch the logic/pins. To prevent corruption

   

of a char being transmitted or received. Or do it async if you do not care if there

   

is any corrupted link activity.

   

 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I understand a "slow" device as using a lot of time to perform its task like sending out data uver UART and waiting for the process to finish. I was not talking about response times.

   

I think muxing the Tx-line can be difficult, because the switching has to occur byte-synced or you will transmit invalid data, but probably you find a solution for that.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

UART and waiting for the process to finish...

   

 

   

I am not following something here. The UART is blocking if it

   

prints a string, otherwise the HW takes over from simple API

   

call to write a byte. Latter tells me the process can be carried out

   

as needed and intermixed with other tasks ?

   

 

   

What am I missing here ?

   

 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

@Dana

   

As I understand, Tom was talking about using interrupts to handle his requirements. Since he said "...event will trigger the need to generate UART data..." I suggested not to handle that within an interrupt handler to keep the system responsive, since the program would have to wait for the complete transmission of the actual character which may take notable time to perform (depending on baud-rate etc)

   

 

   

Bob

0 Likes