Announcements

Webinar: Integrated solutions for smaller, simpler low-voltage motor control design.
Join the webinar to experience!

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

cross mob
Not applicable
Dear all,
I am having a device reset problem (maybe Watchdog timer) when I add UART transmit code to my program. I have the following doubts...
1. I am sending a number Send_Info(1245); by Timer21 interrupt in every 0.3ms. But my device blinks 5 times and reset and so on.Why!
2. And it looks like Program does not go inside while true as I checked with LEDs.!!!

my code as follows

[HTML]#include "tle_device.h"
#include "eval_board.h"
#include
#include
#include

void SendStrings(char *);
void SendFloatNum(float);
void ftoa(float, char *);
void Send_Info(uint32);
char *pBuf; // buffer for ASCII result of a float
char Buf_result[7]; // digits + '.' and allow for '-'



int main(void)
{

TLE_Init();
TIMER21_Start();
CCU6_StartTmr_T12();
// CCU6_StartTmr_T13();




while (1)

{
// PORT_ChangePin(LED1, PORT_ACTION_SET);
// PORT_ChangePin(LED2, PORT_ACTION_SET);

WDT1_Service();

}
}



void SendFloatNum(float num)
{
pBuf = Buf_result;
ftoa(num,pBuf);
SendStrings(Buf_result);
// stdout_putchar('\n');
}

void SendStrings(char *pStr)
{ int i;
for(i = 0; i < (strlen(pStr)); i++)
stdout_putchar(pStr);
}

void Send_Info(uint32 count1)
{
int k;
static uint8 NumPos[6]={0};

NumPos[0]= count1 / 10000 + 0x30; //tenthousand1
NumPos[1]= count1 % 10000 / 1000 + 0x30; //thousand1
NumPos[2]= count1 % 1000 / 100 + 0x30; //hundred1
NumPos[3]= count1 % 100 / 10 + 0x30; //decimal1
NumPos[4]= count1 % 10 + 0x30; //unit1
NumPos[5]= 0x0D; //CR
for(k = 0; k < 6; k++)
{
(void)stdout_putchar(NumPos);
}
}

void ftoa(float f, char *buf)
{
int pos, ix, dp, num;
pos = 0;
ix = 0;
dp = 0;
num = 0;

if (f < 0)
{
buf[pos++] = '-';
f = -f;
}
dp = 0;
while (f >= 10.0)
{
f = f / 10.0;
dp++;
}
for (ix = 1; ix < (6); ix++)
{
num = (int)f;
f = f - num;
buf[pos++] = '0' + num;
if (dp == 0) buf[pos++] = '.';
f = f * 10.0;
dp--;
}
}
void TIMER21_Handle(void)
{
Send_Info(1245);
PORT_ChangePin(LED2, PORT_ACTION_TOGGLE);
}[/HTML]
0 Likes
3 Replies
Mc-Key
Employee
Employee
Welcome!
Dear Litun,

To use the lib you have to enable the sources in the "Manage Run-Time Environment"
2942.attach

In addition you have to activate the MicroLIB checkbox in the "Options for Target" Window.
2943.attach

The easiest way is, using the TTY UART2 Example from the "pack installer":
2944.attach

Please check the Baud rate you are using.
At 9600 Baud your Message will need min. 416µs, which is longer than your actual Timer interval.
In this case your Main() routine will never be executed again. Result: Watchdog Reset!

Did you try to run the code in debug mode?

Best Regards,
M.K.
0 Likes
Not applicable
Thank you, M.K. for sharing those valuable screenshots.

Can you tell how to use UART2 interrupt?

I will be very grateful to you if you could explain the watchdog because many times I face the problem of the watchdog
reset when I do not take care of execution time of certain code inside the interrupt.

I think this printf() function takes a lot of time.

Thanks again.
Regards
S
0 Likes
Mc-Key
Employee
Employee
Welcome!
Hi Litun,
There are some additional informations about the Watchdog WDT1 in the FAQ Application Note.

You can find it here:
https://www.infineon.com/dgdl/Infineon-AppNote-TLE986x-TLE987x-FAQ-Application-Hints_3-AN-v01_00-EN....

The Watchdog WDT1 is described in Chapter 6.

In Case that the link is not functional you will find the document at the Product page:
http://www.infineon.com/tle987x

Beast Regards,
M.K.
0 Likes