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
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 Code:
#include "tle_device.h"
#include "eval_board.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
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[i]);
}
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[k]);
}
}
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);
}