2 Replies Latest reply on Mar 15, 2013 5:58 AM by ki.leung

    UART Implementation

    rocky.marciano

       Hi ,

         

      I want to use UART user module.

         

      I want to send 4 bytes of data from PC to PSOC. 

         

      PSOC when receive should send 2 bytes of data back.

         

      I will use a 4 byte array for rx buffer and 2 byte array for tx buffer.

         

      When 4 bytes data is received interrupt should occur.

         

      How can i implement it 

         

       

         

      regards

         

      Rocky

        • 1. Re: UART Implementation
          user_1377889

          Frankly : you cannot.

             

          An Interrupt can be generated at the receive of EACH character since interrupts in PSoC 1 are related to hardware.

             

          I would suggest to have the number of incoming characters counted (after retrieving and storing them) and when your treshold (or a pre-defined sequence) is reached you set a flag (a global variable) that you inspect in your main-loop and, if set react accordingly (or just inspect the count).

             

           

             

          Happy coding

             

          Bob

          • 2. Re: UART Implementation
            ki.leung

             I normally use a ring buffer, all data receive would be queue up in the ring buffer and the main loop inspect the head and tail pointer. 

               

            if you know the total number of bytes is a fix number, then just do the decoding when the number of bytes received, and if that is correct then send the bytes out.