This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/EK-TM4C123GXL: EK-TM4C123GXL-UART

Part Number: EK-TM4C123GXL
Other Parts Discussed in Thread: BOOSTXL-RS232

Tool/software: Code Composer Studio

Hello i am trying to use following code to update my variables from pc using UART,  but using UARTgetc() i get only single character (i.e if i send 13 i will only receive 3), is there anyway i can get the full number.

Other issue is that i am receiving character but i need integers.

#define TM4C123GH6PM
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_gpio.h"
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/rom_map.h"
#include "driverlib/rom.h"
#include "driverlib/pin_map.h"
#include "driverlib/gpio.h"
#include "driverlib/pwm.h"
#include "driverlib/qei.h"
#include "driverlib/flash.h"
#include "driverlib/adc.h"
#include "driverlib/ssi.h"
#include "inc/tm4c123gh6pm.h"
#include "driverlib/timer.h"
#include "driverlib/interrupt.h"
#include "driverlib/uart.h"
#include "uartstdio.h"
char x;
char y;

int main(void) {
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
UARTFlowControlSet(UART0_BASE, UART_FLOWCONTROL_NONE) ; // Set UART flow control - NONE
IntMasterEnable(); //enable processor interrupts
IntEnable(INT_UART0); //enable the UART interrupt
UARTStdioConfig(0, 115200, 16000000);

while (1) //let interrupt handler do the UART echo function
{
 if (UARTCharsAvail(UART0_BASE))
    {
       y=UARTgetc();

    }
}
}

  • Hi,
    Did you have a chance to try the TivaWare uart_echo example? In the example, a received char will trigger an received interrupt and in the ISR the received char is then echoed back to the terminal.
  • yes it only reads characters one by one and then print them back,but i need to read whole number not single digits(characters).
  • Would not an eased & simple "solution" result from your creating two, "Unique Marker Characters" - one sent just prior to your "whole number" and one sent upon its termination?  

    To illustrate:    #98765*   when sent "Char by Char" via UART,  or  (SPI/I2C/CAN  etc.)  should be easily,  "Reconstructed into 98765."     (you must insure that  "#" is "encoded" - if you wish to use it  - "outside" of its "Signaling Role."  

    The "receive side" is then charged w/the processing required - to "recreate" your original "whole number."

    On the plus side - this should accommodate (almost) any size/length, "whole  (or even fractional) number."

  • it might work, but all the characters received would be stored in different variables, so how can i use them to "recreate" original "whole number".
    Also is there any other way to send data to controller from PC.
  • WHAT ... "might work?"     (You may NOT wish to appoint yourself - (both) Judge & Jury!)     For 20+ years such, "Quick/Dirty" method has been successfully employed by myself  ...  and (many!)

    Are you not (now) exhibiting a tendency to, "Cascade NEW Questions" - while your original question HAS been resolved?

    I'm willing to "assist further" - but you must demonstrate (some) thoughtful effort - in the processing required to "recreate the original (whole number.")

  • Awais Mughal said:
    is there any other way to send data to controller from PC.

    I assume you are using the EK-TM4C123GXL board, in which case, the UART0 functions get data to your PC using the ICDI interface. I believe UART becomes USB on the second micro on the launchpad.

    You can use the USB interface if you want. In the resource explorer, the project "USB Serial Device" does this.

    To truly use serial UART to your PC, you'd have to use some RS-485 or RS-232 chip: http://www.ti.com/tool/boostxl-rs232

    You could also send data to a micro over Ethernet, but that's much more work.

  • i said "might work" because i m trying to apply it but i haven't managed to make it work yet.
  • Indeed - yet your "solution" has "newly arrived" - and (does) require some, "focused time & thought" on your part.

    Newly arrived poster "sheds no light" on your "Data reconstructing objective."     Suggest that you "laser focus" on "that REAL goal"  (method of data transmission is NOT your issue!)

    Once you demonstrate (real) effort - (further) help "will" be forthcoming.     (some profit making activity may intrude - but assistance WILL arrive...) YOU ... CAN DO This!    (Mercî pour la resolution)

  • i was thinking the same, but a vague goal would make more sense coming from a student. This forum would've been valuable back in the undergrad days. Academia doesn't always keep up with trends.

    A student/professional account tag might be helpful
  • P.B.: "A student/professional account tag might be helpful."
    Agreed - and several here - have long suggested such.     (and such WILL be (vendor) considered - immediately  AFTER,  "R9/R10 Plague-Istors" are resolved...)

    Why "keep up" - when the "same old" (DRM anyone) can be ENDLESSLY RE-USED  (effort-lite - mais non?) - even though - especially though - the "STRONG SCENT of INEFFICIENCY"  wafts thru the Classroom?

    You're clever - might you assist this poster in his "Recombination of his Serial Data" efforts?     (past sequence of posts well describes & details...)     I must exit (SELL) for awhile...   (so that staff may "bask" in the pleasing glow of,  "banned" incandescence...)