- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Friends,
How can I send character until there's response ?
I wanna keep sending "UART_1_PutChar(0x01);" until there's response,
Anyone has idea for it ?
Thank you
Here's the code :
UART_1_PutChar(0x01);
Delay10msTimes(50);
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 ");
}
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
can I do :
while(c==' ')
{
UART_1_PutChar(0x01);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried to implement :
Am I putting the right code ?
because I can't get any response eventhough I put if (c !=''), it means RX always empty although I swing the card to the device ? any idea ?
UART_1_PutChar(0x01);
c = UART_1_cGetChar();
if (c !='')
{
P0_0(1);
Delay10msTimes(100);
P0_0(0);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bianchi,
I strongly suggest you to buy an ICE-Cube though it is not a cheap part. The ICE (In-Circuit-Emulator) is able to answer all your Questions within a few seconds and will help you to debug your program / Project within a few minutes so saving you days of trial and reeor. The debug capabilities for PSoC1 are very poor, but the ICE-Cube allows to put breakpoints to any C-line (or asm), inspect or alter variable values watch stack usage and even inspect a trace of the last instructions executed before a breakpoint.
I could not live without one, I bought mine together with my PSoC1 developement kit.
There is an actual offer from Cypress witch does not contain the first POD for the CY8C29466, but that would exactly be what you would need, so you ought to take the more expensive one.
Look at the specs here: http://www.cypress.com/?rID=3411
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since you are communicating with an external device and missing an answer from it, there is something amiss.
1. Can you post your COMPLETE project here, using the "Archive Project" function of Designer 5.3 (and using MS Internet Explorer, not Chrome!) by attaching the .zip with your post.
2. Do you use (does the card-reader need) a level-shifter for the RS232 signals
3. Is the card-reader connected via the 9-pin serial interface? If so
3a. Cable double checked? Compared to the PSoC-Kit schematics?? Jumpers???
3b. Is the card reader using control signals as CTS and RTS
As you see: Serial interface is always a vivid source of adventure, measurement and gnawing fingernails...
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A minor point, change this -
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 ");
}
to this
LCD_clr_line(0);
LCD_clr_line(1);
LCD_1_Position(0,0); // Set LCD position
if (c == 0x01)
{
UART_1_CPutString("Char 0x01 accepted!");
LCD_1_PrCString("Card in ");
}
else
if (c == 0xFE)
{
UART_1_CPutString("Char 0xFE accepted!");
LCD_1_PrCString("Card out ");
}
If you do not have a cube, start using your scope to see if your Rx character
is present. If its a DSO, many can extract clock to make life easy reading
character received. You can also start with a Designer supplied project
that is working and modify it bit by bit. When you open Designer, on opening
screen, is a group pf example projects in "Design Catalog" window.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Debugging communication software is not easy without ICE and CRO.
As others suggest get an ICE or/and a CRO.
for the time being.
void main (void)
{
usinged char ucResponse = 0;
/***
all other program to initalize the UART here
***/
whie (1)
{
ucResponse = 0;
LCD_clr_line(0);
LCD_clr_line(1);
LCD_1_Position(0,0); // Set LCD position
LCD_1_PrCString("Sending 0x01");
do {
UART_1_PutChar(0x01);
Delay10msTimes(50);
/* do a read char, if 0, send 0x01 again, else can start decode the reponse */
/* This is assuming RX to the UART is between 1 and 0xFF */
ucResponse = UART_1_cReadChar();
}while (ucResponse == 0);
LCD_clr_line(0);
LCD_clr_line(1);
LCD_1_Position(0,0); // Set LCD position
if (ucResponse == 0x01)
{
LCD_1_PrCString("Card in ");
}
else
{
if (ucResponse == 0xFE)
{
LCD_1_PrCString("Card Not in ");
}
else
{
LCD_1_PrCString("Unknown response ");
}
}
/* Show the screen for 2 seconds */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@ Dana
Good idea!
But
The first character to send will be swallowed by the Tx buffer and the Putchar() returns. A second character to send would wait (blocking) for the last char beeing transmitted.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
still doesn't work guys,
I suspect the reader is not working properly, since I manually try it with Serial com TX and RX, sending it manually to the reader,
no response at all.....could be broken card reader...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Guys,
The code has been working until :
do {
UART_1_PutChar(0x01);
Delay10msTimes(50);
/* do a read char, if 0, send 0x01 again, else can start decode the reponse */
/* This is assuming RX to the UART is between 1 and 0xFF */
ucResponse = UART_1_cReadChar();
}while (ucResponse == 0);
but not responding to if
if (ucResponse == 0x01)
looks like
ucResponse = UART_1_cReadChar();
not doing its job ??
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried to debug it, see below :
do {
UART_1_PutChar(0x01);
Delay10msTimes(50);
/* do a read char, if 0, send 0x01 again, else can start decode the reponse */
/* This is assuming RX to the UART is between 1 and 0xFF */
ucResponse = UART_1_cReadChar();
Delay10msTimes(50);
LCD_clr_line(0);
LCD_clr_line(1);
LCD_1_Position(0,0); // Set LCD position
LCD_1_PrHexByte(ucResponse);
}while (ucResponse == 0);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Guys, it's not reading anything,
always displaying 00 on LCD.....
it means
ucResponse = UART_1_cReadChar();
is not doing its job.....why is that ????
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you read the data sheet:
char UART_cReadChar(void)
Read RX Data register immediately. If valid data is not available, return 0, else ASCII char between 1 and 255 is returned.
You are getting 0 means valid data is not available.
Are you using a working card reader?
you need to read the data sheet and understand what is going on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The instuction is doing is job, it is saying that data is not valid.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tested card reader with serial port and it's working as it supposed to be....
I don't understand now.....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'll send you guys my video on testing it with serial port later on....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In that case,
I will use the serial port from a PC, connect the 232port to your 232 input, run a program looping to read a char from the UART, with a delay loop to show the result when received. Then send a character from the PC.
Do the following:
1. Wirte a program to constantly sending out a charater from the PSOC to the UART may be once a second, if the realterm get the right charater, then the baud rate, parity and stop bit should be OK.. If not, then make sure wiring is correct, and there are signal going out from the 232 pin port pin. Change the baud rate, parrity and stop bit . you may need to check combinations.of the above If you cannot get this working, don't go to next step
2. Set your program to constantly reading the UART, send a charter from the PC one character at a time. The PSoC program shouel print the received data when a charater is received.
3. If you receve nothing, check the wiring and make sure signal goes to the psoc pin. Change the setting of the UART, most likely be the clock sync, or the RX inpput setting. DONT change the BAUD rate, don't change the stop bits and parity bits.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok,
How can I connect it correctly ? from RFID module to PSoC module ?
is it
Rx to Rx and Tx to Tx or
Rx to Tx and Tx to Rx
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Tx on PSOC goes to Rx on device, Rx on PSOC goes to Tx on device.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do not use the RFID now.
Use the PC to check and make sure the UART is working first
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Test between PC and PSoC board,
PSoC is sending 01 all the time,
but when I sent 01 from PC to PSoC board, it didn't give a proper response
Please have a look on the photo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
this is PC to RFID module test :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Video Test , PC to RFID module,
there's response
http://s129.beta.photobucket.com/user/picture_77/media/PCtoRFIDtest_zps0c2a36d0.mp4.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I change command to 02
Photo :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"Test between PC and PSoC board,
PSoC is sending 01 all the time,
but when I sent 01 from PC to PSoC board, it didn't give a proper response"
Question:
What do you expected from PSoC to reponse to the PC?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you follow what I suggested? and what did you see on the LCD when sending charater from PC to PSOC?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Question:
What do you expected from PSoC to reponse to the PC?
If I send 01 to PSoC from PC, PSoC will display 01 on LCD and print 01 into terminal in PC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you follow what I suggested? and what did you see on the LCD when sending charater from PC to PSOC?
Ans:
Yes I did, LCD gave no response when sending character from PC to PSOC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That means your TX side of PSOC is working, but thre RX side is not working.
1. Check if the wires are correct.
2. Check if there are signal on the PSOC input pin,( if you have aCRO, use a CR), if not you can use a LED with a 10k current limiting resistor, make sure the polarity is right ) you should be able to see a blink on the LED when PC sending data to PSOC, if not, check the circuit again.
3. If you can see the blinking, then check
the I/O option of the pin,
change the clock sync option of the UART,
change the designer to use another pin as the RX.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are making changes, Make ONE and only ONE change at a time. Mark down what happen with that change. If that change doesn't work, change it back to what it was (UNLESS you know it was wrong!), then change another possible options/ setting,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How about change the PSOC program to read RX only and print to LCD when received, Don't do any other things yet., dont send anything, just print what is received, display the data for 1 second, clear the LCD and repeat.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
can I use logic analyzer for it ?
replacing DSO ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure, set it up to trigger on the signal of the RX pin of PSoC, you should be able to capture the data on the line, you can also check if it is the right timing and if pattern is correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@bianchi
90% of RS232 Errors are related to the cabling.
Which connections on your development kit 3210 are you using for the serial interface? JP1 & JP2 or Connector J13?
Are you using Port1 for any purpose?
I STRONGLY suggest you to upload an archive of your project here so that we can check all your settings. Use the "File -> Archive Project..." function in designer to accomplish that. Use MS Internet Explorer when uploading (NOT CHROME!!)
Bob
- 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
Did you test the RX part only as I suggested. What is the result?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you answer the questions...
I asked "Which connections on your development kit 3210 are you using for the serial interface? JP1 & JP2 or Connector J13?"
Or don't you use the 3210 Kit?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You enabled the command-line handler, but you did not work with commands. Using the high-level APIs makes it difficult to debug, better start with the low-level-APIs like reading status, writing one char and so on.
I disabled the command-handler and completed the UART properties you left blank, check if the beaveour changed.
Bob
- 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
Ok Bob,
Thank you very much for the suggestions and the project, I'm looking at it now...
I'll keep in touch....
Do you mind telling me where you are ?