in my project I am sending several data via USBUART to a PC. Now I want to check the data on the other side. So I want to do a CRC calculation on both sides. The receiver sends back the CRC and the sender can cross check the CRC.
There is this CRC component in PSoC, but it needs hardware connections (since it is a hardware component...)
The USBUART component does not have some hardware connections.
So I tried the following, I used a Control Registers at the CRC component and iterate the whole string sending via USBUART through the CRC component. Finally I get a result with that, but I don't like this solution and also I don't get the same CRC on the PC side.
So my question is, how to do a CRC check with data sending via USBUART component in PSoC5?
Thanks a lot in advance,
Why don't you calculate the CRC in software? The CRC component is designed to calculate the checksum for a data stream generated in hardware, which doesn't seem to be your use case.
Thanks for the reply..
Yes, you are right with that. But I tought using the Component would make it more simple and faster (?) to do the calculation.
It might use less CPU time. But as I said, its designed to be used with data supplied by hardware - so you would need a shift register which can put the data to the CRC, and this needs to be handled too. I don't think CRC is that complicated (look at http://en.wikipedia.org/wiki/Computation_of_CRC ).
But USB already does CRC - why do you need another one?
ok, maybe that is the problem in my thinking..
Do I understand it right, that the USB communication ensures that I will always have the correct string transmitted via USBUART? (Because it does a CRC by itself?)
So, when there is an error while transmitting, the USB frame will detect it and will handle it to send the data again?
I'm afraid you are wrong. From the sight of the UART the transmission always works, there's no need to do a CRC calculation and the UART does not know what is on the other side.
CRC-handling is part of the (so called) protocoll and therer you have to define (and to program yourself) what kind of CRC you'll use, what youÄll do if a CRC fails or even (when there is enough redundant data) do an error-detection and correction (Imagine a marsian transmition, where a request to re-send data would take a very long time to fulfill).
In the case the UART receives data you may request that a CRC is calculated and tramsmitted, so you can check it. But that's part of the protocoll as well.
So it is up to you!
Yes, USB does error checking on itself. See, for example here: http://www.tech-pro.net/intro_usb.html . So using the USBUART guarantees ( almost certainly) that the data you send is received by the PC. You still might choose to do an additional layer on security on top of that, to insure against e.g. logical or programming errors. But the transmission itself should be safe.
Oops, sorr5y for a wrong post. I overlooked the "USB" and referred to an ordinary UART-part as in (nearly) each PSoC from 1 to 5.
As most of them have pointed out the USB protocol itself guarantees a reliable data transfer. Also note that for USBUART, bulf endpoints are used, which guarantees accurate dat delivery. You should be fine without your own CRC.