The reset signal of the CRC-component is synchronus to clock, so there must be a reset while a clock pulse comes. The clock pulse will come only while receiving a byte from UART, so there will be at least one bit missing in the CRC.
Since CRC is mostly used to ensure transmission of several bytes(messages) I would suggest to use the Start() and Stoip() APIs to clear the CRC-component.
Another point would be: You have a loop-delay which will be completely unsynchronus to the receiving baud-rate, CRC-generation can be in the middle of a byte, no exact result possibe.
You declared a local loop-variable as "volatile" which is not needed, but you forgot to declare your global "nb"-variable as "volatile" because this is changed in an interrupt handler.
Thanks for you fast answer.
I make the modification that you provide me and made some new test... In the same time, I received an answer from the technical support concerning the CRC in modbus and I can't use it for an external device (in may case IHM) so the only way to check the CRC is by software.
I am interested in your Modbus-RTU implementation, would it be possible to email me the component or project?
Very interesting Olivier. Does it work 100% right?? If so, please contact me via email cause I'm planning to use it on the psoc 5lp platform
Olivier, please contact me as soon as you can, have proposal might interest you. Thanks!
I am looking for MODBUS-RTU slave for PSoC 5lp wonder if we can cooperate on that
Perhaps you want a simple version : PSoC5LP_ModbusSlave.zip
( PSoC4CY8CKIT-059 PSoC 5LP / PSoC Creator 3.3 )
It here (Russian): http://mylab.wmsite.ru/moi-razrab/cypress-psoc/modbus/
I understand that it is necessary to create some logic between UART and CRC components. But i can't set CRC componet up for calculating Modbus RTU CRC. I just slightly change the CRC example project by changing Polynomial Value to 0xA001 and seed value to 0xFFFF, but CRC output does not meet with expected result.
Coud you please give me advice how to right configure CRC component?
My testing confiration you could find in attachment.
My working CRC configuration for Modbus RTU is folowing:
Polynomial value - 0xC002
Seed value - 0xFFFF
Data in - LSB first
result is in format LSB->MSB.
For HW CRC calculation is necessary put 16bit shift register between UART tx_data and CRC di and add simply verilog component that holding CRC component in reset during first 16bits.
I tested HW Rx CRC calculation until maximal uart baud rate 921600 baud/s.