Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

Hi,

I'm a big fan of Infineon's UART component. I use the UART component  (UART_v2_50)  on 90% of my projects I tend to use it in 8N1 mode.   I have no issues with it in this mode.

However in a recent project I've been requested to work on, it uses MARK and SPACE parity in the data across a proprietary LAN to signal all clients special information.

Sadly, I have found that selectively transmitting MARK or SPACE on specific bytes of the packet transmission not to be working correctly.   SPACE parity is the default parity.  I can get it to output MARK parity but not reliably or predictively. 

I have asked on two other threads about receiving an example project from others about a successful MARK/SPACE parity control.   Aside from help from @BiBi_1928986, I've read about others unsuccessful attempts as I achieved.  @BiBi_1928986 provided an example project with a complicated circuit to get around a "logic" issue with the UART_v_2_50 implementation.

To solve this issue in a more 'elegant' (and reliable) solution, I have created my own UART_Tx component with proper MARK/SPACE control on a byte-for-byte basis.   

I looked at 'fixing' the UART_v2_50 component.   This was not going to happen anytime soon.   If you look behind the 'curtain' on this component, you will find it VERY, VERY, VERY complicated.   It has a lot of "bells and whistles" of features to support the ancient UART format along with the modifications that industry has added to it over time.

My component UART_SMTx_v1_00 is a "no-frills" component.  It has the following features and lack of features:

  • UART Tx only.   No Rx is supported.  I found the UART_v2_50 works to detect Rx MARK/SPACE parity correctly.
  • The mode supported is (8MS1)  8-bit data, MARK/SPACE parity, 1 START bit and STOP bit.  See the next note.
  • The component was designed using the UDB Editor.   All the editor design content is included in case you wanted to study or modify it to your needs.  For example, it would be fairly simple to change the data size, the number of STOP bits, etc.
  • UART API functions (Tx-only blocking and non-blocking) are modified to include a parity parameter.  This is to provide familiar API functions with similar functionality.
  • Each UDB has two 4-byte FIFOs.  My version of the component uses BOTH FIFOs.  One is used for the data and the other for the desired parity.  The two FIFOs are loaded in sync with one another to correctly control the desired parity to the byte.   Therefore the blocking and non-blocking UART API functions have been updated with a parity parameter and can be safely queued 4-deep for efficient CPU/application processing.   In theory, with correct loading of the FIFOs (parity first then the data last), DMA can be used.   Note:  This is an improvement over the intended UART_v2_50 implementation.
  • If you have a data array over 4 bytes, use the PutArray() function for blocking or the WriteTxData() with ReadTxStatus() validation for non-blocking.
  • I've provided a Tx_En output for half-duplex or LAN peer-to-peer multiplexing.
  • I've provided a SW selectable interrupt output based on TX_COMPLETE, FIFO_EMPTY, FIFO_NOT_FULL and FIFO_FULL status.
  • Since this component is 'hardcoded' all the parameters are read-only.
  • I have no component datasheet.   However, I have tried to reasonably comment the UDB editor file and the .c and .h files.
  • I have attached a simple demo project that alternates between a polled (blocking) and interrupt (non-blocking) implementation of transfer of a short set of data and parity.
  • In the demo, I send 10 bytes with selected MARK or SPACE parity.   I have included the Infineon UART component to read the transmitted data.   The debugger output to a terminal program displays the data along with the parity detected ('_' prior to the hex data => SPACE ... OR ... hex data without a preface char => MARK.
  • The project was built on a CY8CKIT-059 but can be run virtually any PSoC5LP or PSoC3.   (The PSoC3 may require some minor modifications and have not been tested).
  • The component files are included in the project itself.   It is included in a directory called "UART_SMTx_v1_00".   This simplifies incorporating the component into a new project.   Just drop the entire directory into your new project.

This project is free for your use in your project.  (No warranty is expressed or implied)  You can modify it if needed.

If you have any problems or have suggestions, please post to this forum thread.

Len
"Engineering is an Art. The Art of Compromise."
0 Replies