- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Guys,
How can I see that UART is sending and receiving my command in PSoC designer ?
and what's the meaning of :
PRT0DR |= 0X80;
while(PRT0DR & 0X80)
any helps will be appreciated,
thank you
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using PSoC 1 board from cypress
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you tried the loop back test I suggested.
Here is a project you can check
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
while
{
send 1 byte
read 1 char (use cgetChar)
print the received char.
wait 1 second
}
Like this :while(1)
{
c = UART_1_bReadRxData();
UART_1_SendData(c);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is a project you can check
http://www.cypress.com/?id=4&rID=58574
I have studied that article but it doesn't include on how to receive one character on the RX port.....
does anyone know ?
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have interrupts off, basically in a polled mode.
Can you set up a DSO and capture Tx line from PC to PSOC Rx line to see if
PC is sending out keyboard character ?
When you use this -
UART_cReadChar
- Description:
- Reads UART RX port immediately if data is not available or an error condition exists, or zero is returned. Otherwise, the character is read and returned.
Am I mistaken or does your code read once the character sent to it from PC, then all other
time gets no char, so net effect is you have a very low duty cycle write to display of receiving
a character, alternated most of the time no character received, net effect is you never see the
message chaqracter received on LCD ? Note also you use
byte_length = UART_1_cReadChar();
for (i=0;i<byte_length;i++) {
RxdataBuff = UART_1_cGetChar(); // Get a character from UART RX data register
}
Does the byte_length = character received a non legit value for use as a index into RxdataBuff ?
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
while (1)
{
/* Send one character via the UART TX */
send 1 byte; (eg 'A')
/* rea one character from the RX of UART*/
/* ONLY USE cGetchar(), it would wait forever if not receive */
read 1 char (use cgetChar)
/* print the received charater on LCD, any location would do */
print the received char. to LCD line 1 colum 0
/* a little bit of delay */
wait 1 second
/* print another charter to LCD 1,0 so if a new character is receive */
/* if would be noticed */
print a leter 'B' to LCD line 1,colum 0
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
can you write it in a real code please ? I can't guess what you mean
while (1)
{
/* Send one character via the UART TX */
send 1 byte; (eg 'A')
/* rea one character from the RX of UART*/
/* ONLY USE cGetchar(), it would wait forever if not receive */
read 1 char (use cgetChar)
/* print the received charater on LCD, any location would do */
print the received char. to LCD line 1 colum 0
/* a little bit of delay */
wait 1 second
/* print another charter to LCD 1,0 so if a new character is receive */
/* if would be noticed */
print a leter 'B' to LCD line 1,colum 0
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
while(1)
{
PRT0DR |= 0X80;
while(PRT0DR & 0X80) //Test tag detect signal
{ // low level indicating tag in detection range;
LCD_1_Position(0,0); // high level indicating tag out.
LCD_1_PrString(Notag_Str); // Print "No tag" on the LCD ;
}
UART_1_CmdReset(); // Reset UART Command Buffer
//for (i=0;i<4;i++)
for (i=0;i<1;i++)
{
UART_1_PutChar('a'); // Send a character ('a') to UART TX port
//UART_1_PutChar(sel_card); // Send a character to UART TX port
//UART_bReadTxStatus();
}
UART_1_CmdReset(); // Reset UART Command Buffer
c = UART_1_cGetChar();
if (c =='a')
{
LCD_1_Position(0,0);
LCD_1_PrCString("a char received");
byte_length = UART_1_cGetChar();
for (i=0;i<byte_length;i++)
{
RxdataBuff = UART_1_cGetChar(); // Get a character from UART RX data register
}
LCD_1_Position(0,0);
LCD_1_PrCString("a char received");
switch(RxdataBuff[1]) // Check status byte
{
case 'a':
LCD_1_PrString(Cardf_Str); // Print "Card selected" on the LCD ;
LCD_1_Position(1,0);
LCD_1_PrCString("SN: ");
for (i=2;i<6;i++)
{
LCD_1_PrHexByte(RxdataBuff); // Print serial number of the card detected
}
break;
case 'b':
LCD_1_PrString(Notag_Str); // Print "No tag" on the LCD ;
LCD_clr_line(1);
break;
case 'c':
LCD_1_PrString(Colli_Str); // Print "Collision occur" on the LCD ;
LCD_clr_line(1);
break;
case 'd':
LCD_1_PrString(Chksm_Str); // Print "Checksum error" on the LCD ;
LCD_clr_line(1);
break;
}
}
else
{
LCD_1_Position(0,0);
LCD_1_PrCString("Cardreader error");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i'm not sure this :
c = UART_1_cGetChar();
if (c =='a')
working properly...???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it's better if there's a practical example of receiving character,
since I can send already.....but I can't receive I'm sure the wire connection is right...
P2.7 to TX and P1.6 to RX J13 female header...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it is the first tick.
Did you check if there is a correct RS232 signal to your PSoC RX pin?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried the code :
UART_1_CPutString("Testing UART");
c = UART_1_cGetChar();
while (c !='')
{
UART_1_PutChar(c);
}
I don't understand why cGetChar() doesn't give me any response.....big question mark, I check all the parameter and they're all fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I follow from the schematic :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
P1.6 RX
P2.7 TX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If there is no correct 232 signal at the input pin, even if your software is correct, it will not receive.
Can you check if your have the correct 232 signal on the RX pin of the PSoC?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Got the answer, I must press Enter after I put the character, it works now,
thanks guys...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How can I get the character without pressing enter ?
I need it for detecting card :
while(1)
{
UART_1_CmdReset(); // Reset UART Command Buffer
//Put command to card
UART_1_PutChar(0x01);
c = UART_1_cGetChar(); // how can I take it without waiting for enter button ?
if (c == 0x01)
{
LCD_clr_line(0);
LCD_clr_line(1);
LCD_1_Position(0,0); // Set LCD position
LCD_1_PrCString("Card in ");
}
else
{
LCD_clr_line(0);
LCD_clr_line(1);
LCD_1_Position(0,0); // Set LCD position
LCD_1_PrCString("Card out ");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You mean you need to press ENTER on your laptop to send the 'a' to the PSOC?
I do not use putty so not sure if that can be change, I use realTerm which is a very flexible terminal software. Have a look.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You mean you need to press ENTER on your laptop to send the 'a' to the PSOC?
I do not use putty so not sure if that can be change, I use realTerm which is a very flexible terminal software. Have a look.
Reply :Yup, I need to press ENTER in putty to send character.
How can I receive character without ENTER ? because it's sent from a RFID reader ...
I send a command then the reader will send response which will be received by Cypress (RX) UART_1_cGetChar(), I can't use ENTER button in this point
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think you are using putty to test your program, so I suggest to try realterm because it can send one charater at a time without needing to press ENTER.
I understand that your RFID would resonponse an 'a'.
My suggestion is to use a terminal software so you can control when to send and what to send to your psoc. Once you debug your software and works in a control way using a terminal software. you can use the true RFID to test.
However, it doesn't matter now as you already fix your software.
Happy coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
you mean this one ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To HL,
It's responding to 0x01, but not responding immediately, why is that ?
I'm using the software, you suggested me,
Thanks mate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code :
c = UART_1_cGetChar();
if (c == 0x01)
{
UART_1_CPutString("Char 0x01 accepted!");
LCD_clr_line(0);
LCD_clr_line(1);
LCD_1_Position(0,0); // Set LCD position
LCD_1_PrCString("Card in ");
}
else
if (c == 0xFE)
{
UART_1_CPutString("Char 0xFE accepted!");
LCD_clr_line(0);
LCD_clr_line(1);
LCD_1_Position(0,0); // Set LCD position
LCD_1_PrCString("Card out ");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I manually tested the RFID module through serial port,
it is not working, that's why I can't send command via my PSoC 1 board..