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.

Tiva C Uart Changing UARTCharPutNonBlocking

Other Parts Discussed in Thread: EK-TM4C123GXL

Hi Everyone

Im newbie in tiva c.

I am writing code for adc. It sending with uart.

I am sending adc values.

         a[3] = ulADC0Value[0]%10 + 48;
        ulADC0Value[0] = ulADC0Value[0]/10 ;
        a[2] = ulADC0Value[0]%10 + 48;
        ulADC0Value[0] = ulADC0Value[0]/10 ;
        a[1] = ulADC0Value[0]%10 + 48;
        a[0] = ulADC0Value[0]/10 + 48;
       UARTCharPutNonBlocking(UART0_BASE, a[0]);
            UARTCharPutNonBlocking(UART0_BASE, a[1]); 
            UARTCharPutNonBlocking(UART0_BASE, a[2]);
            UARTCharPutNonBlocking(UART0_BASE, a[3]);

But this sending only one charecter. I want to send data in a line.

Example

            UARTCharPutNonBlocking(UART0_BASE,50);

but its sending only 5 or 0 .

I saw Uartprintf but its in stellaris. It didnt work for tiva c.

 

Waiting Helps

Thanks.

  • Hello Selim,

    The UARTprintf works on TIVA as much as it works on Stellaris parts. Can you check if the FIFO is enabled in UART otherwise that may be the reason it would be missing characters.

    Regards

    Amit

  • Amit Ashara said:

    Hello Selim,

    The UARTprintf works on TIVA as much as it works on Stellaris parts. Can you check if the FIFO is enabled in UART otherwise that may be the reason it would be missing characters.

    Regards

    Amit

    Thanks for ur help.

    How I will found UARTprintf example for TIVA. I searched I found for stellaris they didnt work.

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "inc/hw_gpio.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "driverlib/adc.h"
     
    void UARTAyarla(void)
    {
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
     
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); 
     
    	UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
     
    	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
     
    	UARTFIFOEnable(UART0_BASE); .
     
    	UARTEnable(UART0_BASE);
    }
     
    void ADCAyarla(void)
    {
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); 
     
    	ADCHardwareOversampleConfigure(ADC0_BASE, 64); 
    																								
    	ADCSequenceDisable(ADC0_BASE, 1); 
     
    	ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0); 
    																															  // interrupt'ın değerini 0 yaparak en yüksek önceliği veriyoruz.
     
     
    	ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH0);
    	ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_CH1); 
    	ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_CH2); 
    	ADCSequenceStepConfigure(ADC0_BASE, 1, 3, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END);
    																																									//interrupt'ın açılarak konfigürasyonun tamamlanması
     
    	ADCSequenceEnable(ADC0_BASE, 1); 
     
    int main(void) 
    {
    	uint32_t ulADC0Value[8]; 
     
    	char a[4],b[4],c[4],d[4]; 
    	SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ); 
    	UARTAyarla();
     
    	ADCAyarla();
     
    	while(1)
    	{
    		ADCIntClear(ADC0_BASE, 1);
    		ADCProcessorTrigger(ADC0_BASE, 1);
     
    		while(!ADCIntStatus(ADC0_BASE, 1, false)) 
    		{
    		}
     
    		ADCSequenceDataGet(ADC0_BASE, 1, ulADC0Value); 
     
    		UARTCharPutNonBlocking(UART0_BASE, '@');
    		UARTCharPutNonBlocking(UART0_BASE, ','); 
     
     
    		a[3] = ulADC0Value[0]%10 + 48;
    		ulADC0Value[0] = ulADC0Value[0]/10 ;
    		a[2] = ulADC0Value[0]%10 + 48;
    		ulADC0Value[0] = ulADC0Value[0]/10 ;
    		a[1] = ulADC0Value[0]%10 + 48;
    		a[0] = ulADC0Value[0]/10 + 48;
     
    		b[3] = ulADC0Value[1]%10 + 48;
    		ulADC0Value[1] = ulADC0Value[1]/10 ;
    		b[2] = ulADC0Value[1]%10 + 48;
    		ulADC0Value[1] = ulADC0Value[1]/10 ;
    		b[1] = ulADC0Value[1]%10 + 48;
    		b[0] = ulADC0Value[1]/10 + 48;
     
    		c[3] = ulADC0Value[2]%10 + 48;
    		ulADC0Value[2] = ulADC0Value[2]/10 ;
    		c[2] = ulADC0Value[2]%10 + 48;
    		ulADC0Value[2] = ulADC0Value[2]/10 ;
    		c[1] = ulADC0Value[2]%10 + 48;
    		c[0] = ulADC0Value[2]/10 + 48;
     
    		d[3] = ulADC0Value[3]%10 + 48;
    		ulADC0Value[3] = ulADC0Value[3]/10 ;
    		d[2] = ulADC0Value[3]%10 + 48;
    		ulADC0Value[3] = ulADC0Value[3]/10 ;
    		d[1] = ulADC0Value[3]%10 + 48;
    		d[0] = ulADC0Value[3]/10 + 48;
     
    		UARTCharPutNonBlocking(UART0_BASE, a[0]); 
    		UARTCharPutNonBlocking(UART0_BASE, a[1]);
    		UARTCharPutNonBlocking(UART0_BASE, a[2]);
    		UARTCharPutNonBlocking(UART0_BASE, a[3]);
     
    		UARTCharPutNonBlocking(UART0_BASE, ','); // 
     
    		SysCtlDelay(5000);
     
    		UARTCharPutNonBlocking(UART0_BASE, b[0]); 
    		UARTCharPutNonBlocking(UART0_BASE, b[1]);
    		UARTCharPutNonBlocking(UART0_BASE, b[2]);
    		UARTCharPutNonBlocking(UART0_BASE, b[3]);
     
    		UARTCharPutNonBlocking(UART0_BASE, ','); // 
     
    		SysCtlDelay(5000);
     
    		UARTCharPutNonBlocking(UART0_BASE, c[0]); 
    		UARTCharPutNonBlocking(UART0_BASE, c[1]);
    		UARTCharPutNonBlocking(UART0_BASE, c[2]);
    		UARTCharPutNonBlocking(UART0_BASE, c[3]);
     
    		UARTCharPutNonBlocking(UART0_BASE, ','); 
     
    		SysCtlDelay(5000);
     
    		UARTCharPutNonBlocking(UART0_BASE, d[0]);
    		UARTCharPutNonBlocking(UART0_BASE, d[1]);
    		UARTCharPutNonBlocking(UART0_BASE, d[2]);
    		UARTCharPutNonBlocking(UART0_BASE, d[3]);
     
    		SysCtlDelay(5000);
     
    		UARTCharPutNonBlocking(UART0_BASE, '\n'); 
     
    		SysCtlDelay(1000000); 
    	}

    This is my code.

  • Hello Selim,

    My suspicion is that at the rate you are writing to the buffer, at one point you may start losing the data. The FIFO is not a very large one.

    I am not sure which Tiva Device you are using but the following example code will show how to use the UARTprintf on Tiva Devices.

    C:\ti\TivaWare_C_Series-2.1.0.12573\examples\boards\ek-tm4c123gxl\hello

    Regards

    Amit

  • Hi,

    Also the ADC pins must be configured as analog ones, after enabling the ADC peripheral. 

    Petrei

  • Petrei said:

    Hi,

    Also the ADC pins must be configured as analog ones, after enabling the ADC peripheral. 

    Petrei

    Hi

    How i Will do it?

    Thanks.

  • Amit Ashara said:

    Hello Selim,

    My suspicion is that at the rate you are writing to the buffer, at one point you may start losing the data. The FIFO is not a very large one.

    I am not sure which Tiva Device you are using but the following example code will show how to use the UARTprintf on Tiva Devices.

    C:\ti\TivaWare_C_Series-2.1.0.12573\examples\boards\ek-tm4c123gxl\hello

    Regards

    Amit

    Hi.

    Thanks for help. I used hello code and I used Uartprintf function. 

    Thanks.

  • Hi,

    Use the GPIOPinTypeADC(uint32_t ui32Port, uint8_t ui8Pins) function.

    Read also each function comment in driverlib before its use to better understand all. This will help you more than you can imagine now.

    Petrei