I want to put some debug Messages to the PC, but when the PC not connected the Program hangs in the 'while':
while (USBUART_CDCIsReady() == 0u); // wait until buffer clear
Any solution to get information that PC is ready to receive data?
Have you made the variable Volatile that is inportant. Please post your code.
To declare a variable volatile, include the keyword volatile before or after the data type in the variable definition. For instance both of these declarations will declare foo to be a volatile integer:
volatile int foo;
int volatile foo;
Now, it turns out that pointers to volatile variables are very common. Both of these declarations declare foo to be a pointer to a volatile integer:
volatile int * foo;
int volatile * foo;
Volatile pointers to non-volatile variables are very rare (I think I've used them once), but I'd better go ahead and give you the syntax:
int * volatile foo;
And just for completeness, if you really must have a volatile pointer to a volatile variable, then:
This all are Cypress API Funcioins (USBUART).
Problem is when MCU first sends Data it goes into the USBTXBuffer, but when no PC connected the Data stays in the Buffer, next Time when the MCU sends the next data it will be hangs by "wait until buffer clear".
So I need a Solution to find out if a PC is connected and ready to receive or not...