7 Replies Latest reply on Mar 10, 2012 1:56 PM by user_78878863

    PSoc5 UART_SetRxAddress1 does not work

    ryl.hemus

      I have the RX Address Configuration set to

         

      Address#1 = 1

         

      Address#2 = A

         

      When I call the UART_SetTxsAddress1(2)  the address does not change as I can only communicate on addresses 1 and A.

         

      Is there something else I must do when calling UART_SetTxsAddress1? ie stop and start the UART?

        • 1. Re: PSoc5 UART_SetRxAddress1 does not work
          user_78878863

          How is your UART configured?

             

          - full vs., half duplex

             

          - what address mode do you use?

             

          - how do you read the data (ISR?)

             

          Could it be that there is still data in the buffer which is send to the old address?

             

          hli

          • 2. Re: PSoc5 UART_SetRxAddress1 does not work
            user_78878863

            Oh, and which method is it that you call? The topic says UART_SetRxAddress1, but the posting UART_SetTxAddress1...

            • 3. Re: PSoc5 UART_SetRxAddress1 does not work
              ki.leung

               It would be easier if you upload your project here :-)

              • 4. Re: PSoc5 UART_SetRxAddress1 does not work
                ryl.hemus

                Hi there,

                   

                Thank you for your reply.

                   

                The UART is configured as Full duplex.

                   

                Addressing mode is Byte by Byte.

                   

                I use and ISR to read the data (from the UART doc example)

                   

                I have attached the setup of the UART as a jpg.

                   

                In the code below I added the clear rx and tx buffers as well as the stop and start but this did not help.

                   

                 

                   

                Ryl

                   

                 

                   

                // DOES NOT WORK!!!
                // The UART_485_SetRxAddress1() call does not change the hardware address
                void RS485_SetSensorAddress(int address)
                {
                    char outputStr[80];
                    sprintf(outputStr,"Setting 485 UART address 1 to %d",address);
                    SendUARTMessage(outputStr,1);
                   
                    sprintf(outputStr,"Current address = %d",UART_485_RXADDRESS1_REG);
                    SendUARTMessage(outputStr,1);
                   
                    SendUARTMessage("485 UART TX complete",1);
                   
                    UART_485_ClearRxBuffer();
                    UART_485_ClearTxBuffer();
                   
                    CyDelay(5);

                    UART_485_SetRxAddress1((uint8)address);
                    UART_485_Stop();
                    UART_485_Start();
                   
                    sprintf(outputStr,"Current address = %d",UART_485_RXADDRESS1_REG);
                    SendUARTMessage(outputStr,1);
                   
                    SendUARTMessage("485 UART Address change complete",1);
                   
                }

                • 5. Re: PSoc5 UART_SetRxAddress1 does not work
                  user_78878863

                  The manual says to that (page 8):

                     

                  Software Byte by Byte – Hardware indicates the detection of an address byte
                  (UART_RX_STS_MRKSPC status) for every byte received. Software must read the byte and
                  determine if this address matches the device addresses defined as in the Address #1 or
                  Address #2 parameters or any other additional addresses.
                   

                     

                  I would read this as 'the UART tells the ISR that an addrsss byte has received, but the ISR needs to handle the addressing by itself'. This means that setRxAddress would have no effect, since all addressing is done in software (the manual mentions this on the same page).

                     

                   

                     

                  hli

                  1 of 1 people found this helpful
                  • 6. Re: PSoc5 UART_SetRxAddress1 does not work
                    ryl.hemus

                    Hi hli,

                       

                    Thanks for your help. Yes, I need to use the hardware mode. Now I can change the address of the UART.

                       

                    Ryl