You are here

Communicating with PSoC using Matlab | Cypress Semiconductor

Communicating with PSoC using Matlab

Summary: 5 Replies, Latest post by lavanya.takur_1476526 on 21 Sep 2015 11:33 PM PDT
Verified Answers: 0
Last post
Log in to post new comments.
TImC's picture
11 posts

 I've been trying to control my PSoC code from Matlab via USBUART and have had difficulty sending data from Matlab to the chip.

I have tried impementing both the SPIM_SAR_USB example project and CE60246 (modified for an updated USB interface). Implementing CE60246, I have tried sending data using the fwrite and binblockwrite (I don't think this second one should work).  In both cases, Matlab does not complete the transmission and freezes.

Sending data from the PSoC to Matlab has worked fine, so long as the ..PutData() script is inserted in a forever loop. Sending a receipt acknowledgement from Matlab that would terminate the for loop and allow the program to continue is exactly what I want to do next. Has anybody had similar issues, and if so, is there a solution? 

Thanks for reading

user_119377051's picture
866 posts


I haven't MATLAB and CE60246, however

I was considering something in program of PSoC.

[1] You can see received data by using JTAG or SWD debugger.

What was received data?

... /* Wait for input data from PC */

... while(USBUART_1_DataIsReady() == 0u);

... USBUART_1_GetAll(rdBuffer);


[2] I think, this code is suspicious

... sprintf((char *)wrBuffer, "The ADC_0 channel(%d) is: 0x%4x \n\r\n\r", <--- this ONE

... (int)rdValue, adcReading);


... PrintToUSBUART((char8 *)wrBuffer);

On the Matlab side, will receive two lines.

If so, Is Matlib work correctly?

This might be out of point, I'm not sure.

TImC's picture
11 posts

Hi PSoC73,

Thanks for replying, and for the pointer. I had not considered SWD and do not have a miniprog at my disposal.

The code you cite works on a puTTy-type terminal, pointing to the COM port connected to the PSoC.

However, I have not been able to send a piece of data from matlab using fwrite. That said, the complementary function, fread, works fine, so long as the data to be read is transmitted repeatedly by PSoC.

user_119377051's picture
866 posts

I don know why you couldnt SWD debugging.

What program cable did you use?

Anyway, you need to isolate the problem.

if had no debugger, you can check it LED debug.

Put TestPin_write(0) and TestPin_write(1)

before test point and after test point.

user_14586677's picture
7646 posts

If you do not have a PSOC board for debugging, you can always create a simple

UART link to PC and pass debug info over that, like variable values, port and pin states,

etc. You can get a UART example project by right clicking unselected UART component,

and picking "Find example project". You can add that to you workspace of open in a new

workspace and cut and paste to your target workspace.


Regards, Dana.

lavanya.takur_1476526's picture
2 posts

can anyone help me whether matlab will generate a c code automatically for psoc controller?

Log in to post new comments.