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.

How receive data form matlab on tm4c123gh6pm using Code Composer Studio?

Other Parts Discussed in Thread: ENERGIA

Hi. I want to receive data from matlab. My code is: 

int main (void){

SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
UARTStdioConfig(0, 115200, 16000000);


while(true){

char buffer[128];
int value=0;

if(!UARTCharsAvail(UART0_BASE)){

UARTgets(buffer, sizeof(buffer));
value= (int)atoi(buffer);
value= value+ 1000;
UARTprintf("%4d \n", value);
}
}
}

  • Hi John,

    How do you connect the PC serial signal (RS232) to your TM4C board? Are the COM setup on Matlab and CCS the same (baudrate, stop bit, etc)?

    Regards,
    QJ
  • Hi QJ Wang,

    I'm using RS232 and the same setup in matlab and CCS, but I can't recieve what I send from matlab to the serial port. In matlab I used the command fwrite(). For getting the values of the serial port in CCS I tried to use UARTgets and UARTCharGetNonBlocking, but I didn't get anything.

    Sincerely,
    Jhon

  • Hi Jhon,

    Search Simulink this forum and note several others asking TI for TM4C129 Simulink blocks into to Matlab. Might that mostly require peripheral blocks such as TM4C129x PWM hardware coupling would be good for power testing an inverter bridge Dead Bands insertion to Matlab. This Simulink coupling would be more beneficial as the actual PWM generator can thus drive the simulated inverter in Matlab.

    Not being familiar with CCS ability in Simulink area, that forum has several intuitive folks working in diverse areas.
    It would seem to me CCS to Matlab coupling might require JTAG port XDS100v2 plus configuring a remote port via a Simulink Widget interface in GUI composer.
  • Hi Jhon & BP101

    We have released a MATLAB File Exchange Entry which supports basic programming from Simulink and Embedded Coder for TM4C123G LaunchPads via Energia.  I'm not sure if this is compatible with your project, but it does include Simulink blocks to program basic peripherals.

    Embedded Coder Target for Energia

    -Brian