8 Replies Latest reply on Oct 19, 2018 1:44 AM by julien_horizon Branched from an earlier discussion.

    UART to RS485 - watchdog problem

    julien_horizon

      As a follow on to this closed thread: UART to RS485

       

      What is the difference between P_UART_ISR_TX_FF_MASK and P_UART_ISR_TX_FAE_MASK ?

       

      Do you have some example about UART callback transmission ?

        • 1. Re: UART to RS485
          julien_horizon

          Since I use a callback tx uart I have a watchdog reset problem:

           

          My board periodicly receive uart data and send data tx response.

           

          This is my uart Init:

           

          static void tw_puart_init(UINT8 rxPortPin, UINT8 txPortPin, UINT32 bdRate)

          {

              extern puart_UartConfig puart_config;

              puart_config.baudrate = bdRate;            // Set the baud rate we want to use.

              puart_selectUartPads(rxPortPin, txPortPin, 0x00, 0x00);

              puart_init();

              puart_flowOff();

              devlpm_init();

              devlpm_registerForLowPowerQueries(uart_device_lpm_queriable, 0);

           

              P_UART_INT_CLEAR(P_UART_ISR_RX_AFF_MASK);

              P_UART_WATER_MARK_RX_LEVEL(1);

              P_UART_INT_ENABLE |= P_UART_ISR_RX_AFF_MASK;

              P_UART_WATER_MARK_TX_LEVEL(1);

              P_UART_INT_ENABLE |= P_UART_ISR_TX_FAE_MASK;//P_UART_ISR_TX_FF_MASK;

              puart_txCb = puart_control_tx_callback;

              //puart_enableTx();          // With and Without, I have the same problems

              puart_rxCb = puart_control_rx_callback;  

               puart_enableInterrupt();

          }

           

          and In my tx callback:

           

          static void puart_control_tx_callback(void)//* unused)

          {

              P_UART_INT_CLEAR(P_UART_ISR_TX_FAE_MASK);

              data2send--;

              if(data2send <= 0)

              {

                  gpio_setPinOutput(GPIO_DE_RS485 / 16, GPIO_DE_RS485 % 16, CS_DEASSERT);

                  gpio_setPinOutput(GPIO_RE_RS485 / 16, GPIO_RE_RS485 % 16, CS_DEASSERT);

                  data2send = 0;

              }

              P_UART_INT_ENABLE |= P_UART_ISR_TX_FAE_MASK;

          }

           

          In my application I send datas with puart_write() and I increment the data2send flag. When data2send is null, All datas is sent and i reverse my rs485 in reception mode.

           

          This works fine when I send data. But when I don't send data, the watchdog reset each 4-5sec. I have try with watchdog disabled and the problem disappears. Why my watchdog reset when I do nothing with the UART?

          When I comment this

          P_UART_WATER_MARK_TX_LEVEL(1);

              P_UART_INT_ENABLE |= P_UART_ISR_TX_FAE_MASK;//P_UART_ISR_TX_FF_MASK;

              puart_txCb = puart_control_tx_callback;

              //puart_enableTx();          // With and Without, I have the same problems

           

          I can't transmit data but the reset problem is solved...

           

          Do you have any explanation?

           

          Thanks

          • 2. Re: UART to RS485
            julien_horizon

            More specificly, in my tx callback function, I move the wdog_configure() function before and after the gpio_setPinOutput() function and It's works fine.

             

            static void puart_control_tx_callback(void)//* unused)

            {

                P_UART_INT_CLEAR(P_UART_ISR_TX_FAE_MASK);

                P_UART_INT_ENABLE |= P_UART_ISR_TX_FAE_MASK;

                data2send--;

                if(data2send <= 0)

                {

                    wdog_configure(FALSE);

                    gpio_setPinOutput(GPIO_DE_RS485 / 16, GPIO_DE_RS485 % 16, CS_DEASSERT);

                    gpio_setPinOutput(GPIO_RE_RS485 / 16, GPIO_RE_RS485 % 16, CS_DEASSERT);

                    data2send = 0;

                    wdog_configure(TRUE);

                }

            }

             

            I don't understand why the setPinOutput function is the cause of my watchdog problem... any idea?

            • 3. Re: UART to RS485 - watchdog problem
              MichaelF_56

              Adding a few members of the Applications team: grsr riya rroy zhez zhxh yans kavs shjl

              • 4. Re: UART to RS485 - watchdog problem
                julien_horizon

                Nobody can help me about my watchdog problem?

                • 5. Re: UART to RS485 - watchdog problem
                  MichaelF_56

                  I will ask the apps team to take a look.

                  • 6. Re: UART to RS485 - watchdog problem
                    julien_horizon

                    A last UP before I surrender

                    • 7. Re: UART to RS485 - watchdog problem
                      ZhengbaoZ_96

                      Hi:

                       

                      just a suggestion ,  Can you add the TX enable  in puart_control_tx_callback to avoid watch dog occurring ?

                      not to add them in the init function.

                      puart_enableTx();

                      puart_disableTx();

                      2 of 2 people found this helpful
                      • 8. Re: UART to RS485 - watchdog problem
                        julien_horizon

                        Thanks a lot

                         

                        The solution is to add puart_enableTx() in the callback function and not in the init.