From: Marko Mattila <markotmattila@gm...> - 2011-10-25 13:19:04
This is question mostly for JP. When you write the mpipe code why you
decided to close the UART after transmissions by hand? UART_CLOSE command.
The uart goes to IDLE state automatically after the last byte is sent
from the fifo. What is the need for turning it off manually?
I am asking this because i have been trying to implement the UART_CLOSE
so that all bytes are transmitted but not extra junk is sent. I see that
there is two possible solutions. One is to add extra bytes and close
the uart too early like now. The the problem of this approach is junk
byte is sent to the uart every now and then.
Another possibility is to use the status bit while(UC_STAT & UCBUSY); to
check when the transmission is ready. The problem on this approach is
that this is blocking the isr.
ISR can not be used because TX interrupt of the USCI_A0_VECTOR is set
when the last byte is transferred from transmit buffer to fifo. Not when
it is sent from uart to wire.
If there is not good reason to call the UART_CLOSE easiest solution to
the problem is just not to call the UART_CLOSE manually.
On 25 Oct 2011, at 06:18, Marko Mattila wrote:
> This is question mostly for JP. When you write the mpipe code why you
> decided to close the UART after transmissions by hand? UART_CLOSE command.
> The uart goes to IDLE state automatically after the last byte is sent
> from the fifo. What is the need for turning it off manually?
I'm probably just used to working on older HW that doesn't have automatic UARTs, or maybe I didn't see the part in the user's guide that explains that the DMA manages the UART automatically. I don't think I had a conscious reason for manually closing UART, except maybe for documentation purposes. Since the Mpipe driver is not universal (it is a device driver, and we will have to port it to other devices when the time comes), then please remove the manual closing parts if they make the implementation better. Removing the manual closing should probably reduce compile-size by several bytes, and making the code smaller is ALWAYS going to get my approval. :)
For the record:
I spent several days trying to find good code resources for using the UART on the MSP430. There are none. In fact, any kind of available free code for MSP430 is almost complete crap. Now there is OpenTag, which actually uses the DMA and (when it works) has acknowledgement. So we are the first to do this for the MSP430 in a non-proprietary way. TI should buy us all ice cream.