Scott, see my answer to your post:
http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/p/126576/453324.aspx#453324
Jim Smith
PS: I had tried (and failed, miserably) to come up with a device driver, as you
mentioned below. That's when I started this thread and started getting
helpful suggestions right away!
--- In m..., "swhitney14" wrote:
>
> Jim,
>
> This looks like terrific work, and thanks to you and to Hardy. I have been
trying to find out how to actually install a device driver using CCSv4, and the
documentation is pretty useless. The manual only talks about writing open(),
close(), read(), write(), rename(), unlink(), and then installing the new device
driver using add_device(). Sounds great, but I cannot find any decent examples
of connecting a serial port in this manner. At least your method provides a
reasonable alternative.
>
> On the flip side, have you or anyone else in the group written some code to
implement an equivalent of scanf() for UART input? Formatted I/O in both
directions is essential for the project I am working on, so any pointers are
greatly appreciated!
>
> Also, it would be helpful to have the transmit interrupt handler installed, so
that busy-wait loops for the transmit buffer to become empty could be avoided.
In many embedded "super-loop" applications, having to sit in a busy-wait for any
extended period of time is going to negatively impact overall system
performance.
>
> I plan to try your posted solution on the printf() side, and also am looking
forward to hearing about possible scanf() implementations for a UART. I have
asked this question on the TI E2E board, but no luck so far...
>
> Scott
>
printf to UART - Revisited - CCSv4
Started by ●July 31, 2011
Reply by ●August 5, 20112011-08-05
Reply by ●August 5, 20112011-08-05
Hi Jim,
Thank you for the link and the fast answer. Your example looks great, and I have been able to implement printf, putc, and puts on uartA1 on my board. I cannot imagine how much longer it would have taken without your help and that of the others in this group. The CCSv4 documentation on device drivers is simply dismal, and not having an out-of-the-box way to connect the standard I/O to an on-chip resource is nearly inexcusable. Good for IAR users, I guess.
Regarding the second part of my question, has anyone come up with an equivalent solution for scanf/gets/getc? Formatted input is equally important to us, and would greatly help with generation of a more elaborate command parser for development testing and field use.
I assume that similar low-level routines are available for the innards of scanf, and there may be routines that we can replace for something like _inc() and _ins(), similar to _outc() and _outs().
Also, has anyone implemented a buffering scheme to provide interrupt driven transmission of output data to prevent the "busy-wait" required for something like:
while(!IFG2 & UCA0TXIFG) ; // wait for room in Tx register
Thanks again, Jim and Hardy!
Thank you for the link and the fast answer. Your example looks great, and I have been able to implement printf, putc, and puts on uartA1 on my board. I cannot imagine how much longer it would have taken without your help and that of the others in this group. The CCSv4 documentation on device drivers is simply dismal, and not having an out-of-the-box way to connect the standard I/O to an on-chip resource is nearly inexcusable. Good for IAR users, I guess.
Regarding the second part of my question, has anyone come up with an equivalent solution for scanf/gets/getc? Formatted input is equally important to us, and would greatly help with generation of a more elaborate command parser for development testing and field use.
I assume that similar low-level routines are available for the innards of scanf, and there may be routines that we can replace for something like _inc() and _ins(), similar to _outc() and _outs().
Also, has anyone implemented a buffering scheme to provide interrupt driven transmission of output data to prevent the "busy-wait" required for something like:
while(!IFG2 & UCA0TXIFG) ; // wait for room in Tx register
Thanks again, Jim and Hardy!
Reply by ●August 5, 20112011-08-05
Scott, take a look at the interrupt-driven input of my posting to the TI e2e
site. Using that technique, you can collect the input string, saving it in an
input buffer via interrupt, let the interrupt routine notify main() when the
string terminator arrives, then process the string in main() (outside the
interrupt), with something like:
sscanf( Inbuf, fmt, ...);.
That eliminates the input wait-loop that you mentioned.
In my example, the input interrupt routine is not putting the incoming characters into Inbuf, but is only sending a flag to main(), and main() is printing out a simple response, just to show that the technique works.
Hope this helps,
Jim Smith
--- In m..., "swhitney14" wrote:
>
> Hi Jim,
>
> Thank you for the link and the fast answer. Your example looks great, and I have been able to implement printf, putc, and puts on uartA1 on my board. I cannot imagine how much longer it would have taken without your help and that of the others in this group. The CCSv4 documentation on device drivers is simply dismal, and not having an out-of-the-box way to connect the standard I/O to an on-chip resource is nearly inexcusable. Good for IAR users, I guess.
>
> Regarding the second part of my question, has anyone come up with an equivalent solution for scanf/gets/getc? Formatted input is equally important to us, and would greatly help with generation of a more elaborate command parser for development testing and field use.
>
> I assume that similar low-level routines are available for the innards of scanf, and there may be routines that we can replace for something like _inc() and _ins(), similar to _outc() and _outs().
>
> Also, has anyone implemented a buffering scheme to provide interrupt driven transmission of output data to prevent the "busy-wait" required for something like:
>
> while(!IFG2 & UCA0TXIFG) ; // wait for room in Tx register
>
> Thanks again, Jim and Hardy!
>
sscanf( Inbuf, fmt, ...);.
That eliminates the input wait-loop that you mentioned.
In my example, the input interrupt routine is not putting the incoming characters into Inbuf, but is only sending a flag to main(), and main() is printing out a simple response, just to show that the technique works.
Hope this helps,
Jim Smith
--- In m..., "swhitney14" wrote:
>
> Hi Jim,
>
> Thank you for the link and the fast answer. Your example looks great, and I have been able to implement printf, putc, and puts on uartA1 on my board. I cannot imagine how much longer it would have taken without your help and that of the others in this group. The CCSv4 documentation on device drivers is simply dismal, and not having an out-of-the-box way to connect the standard I/O to an on-chip resource is nearly inexcusable. Good for IAR users, I guess.
>
> Regarding the second part of my question, has anyone come up with an equivalent solution for scanf/gets/getc? Formatted input is equally important to us, and would greatly help with generation of a more elaborate command parser for development testing and field use.
>
> I assume that similar low-level routines are available for the innards of scanf, and there may be routines that we can replace for something like _inc() and _ins(), similar to _outc() and _outs().
>
> Also, has anyone implemented a buffering scheme to provide interrupt driven transmission of output data to prevent the "busy-wait" required for something like:
>
> while(!IFG2 & UCA0TXIFG) ; // wait for room in Tx register
>
> Thanks again, Jim and Hardy!
>