System Reset occurs on receiving data over UART interrupt

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

cross mob
Anonymous
Not applicable

Hi,

I am facing an issue that my system reset occur when I receive the data on UART (85 byte stream). I'm using as describe:

1- In UART receive Interrupt function bytes are taken from FIFO

2- Parser is looking for specific Bytes from interface module

3- on receiving right data it is push in array of 85

4- when array gets full variable is set for transmission over notification API

5-watch dog is reset on receiving every byte

Please let me know what is going wrong in my system and how to fix it. my code is as below:

Have a nice day!

Kind Regards,

Ghalib

Code is as below: ws_upgrade_uart.c

extern UINT8 hrm_char1;

static UINT8 num_bytes_received = 0;

extern UINT8 over_above;

extern UINT8 buffer[10];

extern UINT8 noti_tx;

extern UINT8  hrm_chk[100];

void ws_upgrade_uart_interrupt_callback(void* unused)

{

    char  readbyte;

    int   send_status = FALSE;

    // empty the FIFO

    while(puart_rxFifoNotEmpty() && puart_read(&readbyte))

         {

                   buffer[num_bytes_received ]=readbyte;

                      if (buffer[num_bytes_received] > 0xf7)// FD=247

                                {

                                     if (buffer[num_bytes_received] == 0xf8 ) //wave block

                                          {

                                               inc_dec++;

                                          }

                      else if (buffer[num_bytes_received] == 0xfe)

                                     {

                                        //do nothing

                                    }

                      else if ((buffer[num_bytes_received] == 0xf9) || (buffer[num_bytes_received] == 0xfa)) //value block

                                     {

                                        //do nothing

                                     }

                      else if (buffer[num_bytes_received] == 0xfc) //status block (transmitted once per second)

                                     {

                                     }

                      else if (buffer[num_bytes_received] == 0xff)

                                     {

                                     //Status = buf;

                                     }

                           }

            if (inc_dec == 2 && buffer[num_bytes_received - 3] == 0xf8)

                  {

                      inc_dec--;

                      hrm_char1=buffer[num_bytes_received - 1];

                      num_bytes_received = 0;

            if (noti_tx == 0 )

                 hrm_chk[over_above++]=hrm_char1;

            if (over_above == 32)

                      {

                 noti_tx++;

                 over_above=0;

                      }

                 }

            else if(num_bytes_received>7)

                      {

                      inc_dec=0;

                      num_bytes_received = 0;

                      }

               // Received all - do something with it.

                 num_bytes_received++;

                  wdog_restart(); 

    }// while ends

    // clear the interrupt

    P_UART_INT_CLEAR(P_UART_ISR_RX_AFF_MASK);

    // enable UART interrupt in the Main Interrupt Controller and RX Almost Full in the UART Interrupt Controller

    P_UART_INT_ENABLE |= P_UART_ISR_RX_AFF_MASK;

    if (send_status)

    {

        ws_upgrade_uart_send_status(WS_UPGRADE_EVENT_OK);

    }

   // make sure that watch dog is ok

}

code heart_rate_monitor.c

UINT8 hrm_chk[35];

UINT8 hrm_char1;

UINT8 buffer[10];

UINT8 over_above;

UINT8 noti_tx=0;

void heart_rate_monitor_FineTimeout(UINT32 count)

{

            if (config_var == 0)

                 {

                 ECG_config();

                 config_var++;

                 }

            if (noti_tx == 1)

                 {

                   bleprofile_sendNotification(hrmAppState->blehrm_hrm_hdl, hrm_chk, (sizeof(hrm_chk)));

                   noti_tx = 0;

                }

}

0 Likes
4 Replies
BoonT_56
Employee
Employee
500 likes received 250 likes received 100 likes received

Did you have flow control? CTS and RTS? Otherwise you may want to consider one.

The receiver fifo buffer is 16 bytes, and some folks have implemented watermarks to circumvent

the issue.

// clear interrupt

  P_UART_INT_CLEAR(P_UART_ISR_RX_AFF_MASK);

  // set watermark to 1 byte - will interrupt on every byte received.

  P_UART_WATER_MARK_RX_LEVEL (1);

Do refer to the below for more details:

Connecting an external board to the BCM2073X via the PUART

Anonymous
Not applicable

Many many thanks for your reply.

I don't have flow control (RTS & CTS) as module I am interfacing don't have these signal lines.

I am using the same example you have attached and I have also added the watermark but things are still not working out well.

Kindly let me know how I can resolve this issue, please...

Have a nice day!

Regards,

Ghalib

0 Likes

I thought the "buffer" in your modified ws_upgrade_uart.c should be set to at least 90: 

extern UINT8 buffer[10];

What is your baud rate? Do ensure the following lines in your app:

puart_init();

puart_setBaudrate(0,0,9600); // just happened to choose 9600, default is 115200

puart_flowOff(); // turned off flow control explicitly

Below is a thread on this topic:

Re: Long Data from UART

lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Many many thanks. Sorry my mistake, I reduced the size of buffer to 35 during debugging.

I'm using baud rate of 115200 and wasn't not turning off the flow control explicitly but now have turned off the flow control explicitly but no improvements.

Can you suggest me what can be possible issue as watch dog timer reset system for action over 2Second but my reset is triggered almost in time interval of >4Sec. Let me know how I can disable the watchdog timer to confirm that its watch dog triggered reset. when I want to open header or source file for wdog_restart(); with F3 key it open blank glcouse_meter.c which don't exist. Can you tell about its source file, Please. Kindly let me how to fix reset issue.

I have attached the code for your perusal.

Waiting for your guidance.

Regards,

Ghalib

Code is as below (showed only the relevant part here)

blehrm.c

PLACE_IN_DROM const BLE_PROFILE_PUART_CFG blehrm_puart_cfg =

{

    /*.baudrate  =*/ 115200,

    /*.txpin      =*/ 32,      // GPIO pin number 20730A0 module need to use 32 instead

    /*.rxpin      =*/ 33,      // GPIO pin number

};

Heart_rate_monitor.C

#include "blehrm.h"

extern const BLE_PROFILE_PUART_CFG blehrm_puart_cfg;

APPLICATION_INIT()

{

    bleapp_set_cfg((UINT8 *)heart_rate_monitor_db_data,

                  sizeof(heart_rate_monitor_db_data),

                  (void *)&heart_rate_monitor_cfg,

                  (void *)&blehrm_puart_cfg,

                  (void *)&blehrm_gpio_cfg,

                  heart_rate_monitor_create);

}

void heart_rate_monitor_create(void)

{

    bleprofile_Init(bleprofile_p_cfg);

    puart_flowOff();

    ws_upgrade_uart_init(&blehrm_puart_cfg, application_puart_interrupt_callback);

}

0 Likes