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.

Connected Launchpad communication with LabVIEW via UART

Hi all,

I'm trying to develop a simple GUI based on LabVIEW to communicate with the TIVA C series Connected Launchpad. In the attached file, I try to switch on and off LED1 on the launchpad using string commands over RS232. I used UART0 and connected the launchpad to the PC via the serial over USB port (debugging port).

I tested my code using Hercules terminal and it Works fine.

The problem is that when I use LabVIEW's VISA driver, it doesn't work. The UART0 module on TIVA is programmed to work at a baudrate of 115200 Kbps. When I configure the VISA open function for that baud rate, it doesn't work. The most curious thing is that when I configure it for 9600 Kbps, it opens the port! and then sends characters to TIVA, but the launchpad doesn't respond.

On the other hand, when I set the hercules terminal for 115200 Kbps, it successfully opens the port and sends commands to the TIVA and it responds and switches on and off LED1 accordingly.

Best regards,

Ahmed.

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/timer.h"
#include "driverlib/pin_map.h"
#include "driverlib/adc.h"


uint32_t g_ui32FrecuenciaRelojSistema;


void UARTIntHandler(void)
{
	char RS232Caracter;
    UARTIntClear(UART0_BASE, UART_INT_RX | UART_INT_RT);
    while(UARTCharsAvail(UART0_BASE))
    {
    	RS232Caracter = (unsigned char)(UARTCharGetNonBlocking(UART0_BASE) & 0xFF);

    	switch(RS232Caracter)
    	{

    	case 'E': GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, GPIO_PIN_1); break;  //Encender LED1.

    	case 'A': GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, 0); break;			 //Apagar LED1.

    	case 'L': UARTCharPutNonBlocking(UART0_BASE, GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_1|GPIO_PIN_0)); break;
    	}
    }
}

void ConfigurarTemp0(void)
{
    //Activar el periferico del temporizador 0
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);

	//Configurar en modo periodico
	TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);

	//Configurar el periodo del temporizador
	TimerLoadSet(TIMER0_BASE, TIMER_A, g_ui32FrecuenciaRelojSistema/4);

	IntMasterEnable();
	//Activar la interrupci�n del temporizador 0
	IntEnable(INT_TIMER0A);
	TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

	//Activar el temporizador 0
	TimerEnable(TIMER0_BASE, TIMER_A);
}

void ConfigurarLeds(void)
{
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);

	GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1|GPIO_PIN_0);
}

void ConfigurarUART0(void)
{
    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);
    UARTConfigSetExpClk(UART0_BASE, g_ui32FrecuenciaRelojSistema, 115200, (UART_CONFIG_WLEN_8|UART_CONFIG_STOP_ONE|UART_CONFIG_PAR_NONE));
    IntEnable(INT_UART0);
    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
}

/*void UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
	uint32_t ui32indiceCaracter;
    for(ui32indiceCaracter = 0; ui32indiceCaracter < ui32Count; ui32indiceCaracter++)
    {
        UARTCharPutNonBlocking(UART0_BASE, *pui8Buffer++);
    }
}
*/
void ManejInterrupTemp0(void)
{
	TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

	//Leer el estado del LED1 y inviertelo y pon el LED2 al estado contrario
	if(GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_0))
		// Apagar LED2
		GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0);
	else                                            //Pues LED2 est� apagado
		// Encender LED2.
		GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 1);
}

void main(void)
{

	g_ui32FrecuenciaRelojSistema = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN |SYSCTL_USE_PLL |SYSCTL_CFG_VCO_480), 120000000);

	ConfigurarLeds();

    ConfigurarTemp0();

    ConfigurarUART0();

//    UARTSend((uint8_t *)"\nEnter text:", strlen("\nEnter text:"));

    while(1)
    {
    }
}