cancel
Showing results for 
Search instead for 
Did you mean: 

Smart Bluetooth

Juar_2150386
New Contributor II

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 ?

0 Likes
1 Solution
Zhengbao_Zhang
Moderator
Moderator

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();

View solution in original post

8 Replies
Juar_2150386
New Contributor II

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

0 Likes
Juar_2150386
New Contributor II

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?

0 Likes
MichaelF_56
Moderator
Moderator

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

0 Likes
Juar_2150386
New Contributor II

Nobody can help me about my watchdog problem?

0 Likes
MichaelF_56
Moderator
Moderator

I will ask the apps team to take a look.

Juar_2150386
New Contributor II

A last UP before I surrender

0 Likes
Zhengbao_Zhang
Moderator
Moderator

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();

View solution in original post

Juar_2150386
New Contributor II

Thanks a lot

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

0 Likes