- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;
}
}