Announcements

Ever wondered how you could shape the future in collaboration with others? Join us at OktoberTech Asia Pacific and get inspired. Click here to sign up FREE of charge.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 5, 3 & 1 Forum Discussions

b4balu
Level 1
First like given First reply posted First question asked
Level 1

I have been trying to write a program that involves Digital Write and USBUART. The program doesn't seem to work for some reason. 

This is a sample code. When I comment out the digital write statements, the USBUART works. And when I comment out the USBUART, the Digitalwrite works. Any idea why?

Any help is greatly appreciated.

#include "project.h"
#include <stdio.h>
int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */

    ADC_SAR_Start();
    AMux_Start();
    USBUART_Start(0,USBUART_5V_OPERATION);
    
    while(USBUART_GetConfiguration()==0){}
    
    ADC_SAR_StartConvert();
    
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

    for(;;)
    {
        /* Place your application code here. */
        
        LED_Write(1);
        CyDelay(1000);
        LED_Write(0);
        CyDelay(1000);
        
        AMux_Select(0);
        int pot1 = ADC_SAR_GetResult16(); 
        AMux_Select(1);
        int pot2 = ADC_SAR_GetResult16();
        
        char print[100];
        sprintf(print, "pot1 : %d, pot2 : %d\r\n", pot1, pot2);
        USBUART_PutString(print);
        CyDelay(100);
        
    }
}
0 Likes
1 Solution
sk7211
Moderator
Moderator 50 sign-ins 5 solutions authored 10 replies posted
Moderator

Hi @b4balu 

Thanks for waiting, I agree with @Len_CONSULTRON,  the code implementation is correct, for your reference I have attached the tera term screenshot.

Can you please, ensure the connection of the USB type B to the PC. 

Please, let us know your hardware setup.

Thank you

Best Regards

Sahil Kumar

View solution in original post

5 Replies
pacr_284376
Level 4
5 solutions authored 25 sign-ins 50 replies posted
Level 4

Could you please show your complete project or at least the PIN definitions and CySch schematic ?

Are you using a developmentboard, which one ?

0 Likes
b4balu
Level 1
First like given First reply posted First question asked
Level 1

Hi,

I am using  PSoC 5LP CY8C5888LTI-LP097.  Please have a look at the pin configuration and schematic. Did I overlook something obvious?

Cysch.png

Schematic

Pin_assignment.png

Pin assignment

Pin_config.png 

Pin configuration

0 Likes
Len_CONSULTRON
Level 9
1000 replies posted 750 replies posted 500 likes received
Level 9
I tried your project with the code, schematic and pins you provided on my CY8CKIT-059.
I have NO PROBLEM!!!
The LED flashes with 1s ON and 1s OFF and I get USBUART output.
I didn't have to comment anything.
Len
"Engineering is an Art. The Art of Compromise."
sk7211
Moderator
Moderator 50 sign-ins 5 solutions authored 10 replies posted
Moderator

Hi @b4balu 

Thanks for waiting, I agree with @Len_CONSULTRON,  the code implementation is correct, for your reference I have attached the tera term screenshot.

Can you please, ensure the connection of the USB type B to the PC. 

Please, let us know your hardware setup.

Thank you

Best Regards

Sahil Kumar

b4balu
Level 1
First like given First reply posted First question asked
Level 1

Thank you @Len_CONSULTRON and @sk7211 for trying it out and responding to the post. I hadn't connected the USB B port to the target device side (had just got the PSoC a few days back) as I didn't quite know how to use it. Also, my USB type B cable was faulty as well.

0 Likes