eTPU based serial

Discussion to talk about software related topics only.
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: eTPU based serial

Post by lgitlitz »

The RTS version of this UART will not help with 485. This signal is asserted when the receive buffer is empty to tell the connected device it can send more data. This is not at all related to the transmitter. The normal hardware UART (not the etpu) on this processor has a special function for 485 mode. When enabled it will change the RTS signal from "able to receive" to "done transmitting".

Most UARTs I have used must specifically support some 485 mode if you want to be able to use half-duplex 485 without some timer software to disable the transmitter. This is because most UARTs will only tell you when the transmit buffer is empty, this is not the same as the TX shift register that is actually sending the data. The eTPU UART works this way too, it is called double buffered transmitter. You first put data in the TX buffer of the UART. The CPU will then assert a flag to tell you that the TX buffer is full and you need to wait before giving it any more data. If the UART has completed the transmit of any previous data it will then move this new TX buffer data into a TX shift register. As soon as this happens the CPU will de-assert the TX flag to tell you that it is OK to put more data into the TX buffer. This does not indicate if the transmit is completed, it actually indicates that the transmit is about to begin. There is no indication when the transmit is completed or the TX shift register is empty.

The software solution mentioned in earlier posts is really the best option here if you cant use one of the hardware UARTs. A timer the length of a single packet transmission should be enabled after the TX buffered is emptied on your last transmit byte. When the timer interrupts you know that the transmit has completed and you can manually toggle the enable.
v8dave
Posts: 333
Joined: Thu Dec 31, 2009 8:31 pm

Re: eTPU based serial

Post by v8dave »

Hi all,

I am waiting on some 3V3 RS485 drivers to come in and then I will have a go at trying to work this out. If there was only a way to know when the eTPU buffer was empty, it would simplify matters considerably.

Dave...
v8dave
Posts: 333
Joined: Thu Dec 31, 2009 8:31 pm

Re: eTPU based serial

Post by v8dave »

Hi all, just a quick update.

I found an application note and code for the eTPU UARTS and found this code which may be just what I need to wait for the changing of RS485 from TX to RX.


while (ETPU.CHAN[TX_CHANNEL].SCR.B.CIS == 0)
{
/* wait for data to transmit */
}

Dave...
Post Reply