+ Reply to Thread
Results 1 to 4 of 4

Thread: [SOLVED] TLE987x(Eval Kit) reset problem when UART added

  1. #1
    New Member New Member Litun is on a distinguished road
    Join Date
    Aug 2017
    Posts
    26
    Points
    196.25

    [SOLVED] TLE987x(Eval Kit) reset problem when UART added

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

  2. #2

    Infineon Employee
    Infineon Employee
    Mc-Key will become famous soon enough
    Join Date
    Jan 2018
    Location
    Germany
    Posts
    28
    Dear Litun,

    To use the <stdio.h> lib you have to enable the sources in the "Manage Run-Time Environment"
    Click image for larger version

Name:	MRTE.PNG
Views:	0
Size:	18.2 KB
ID:	3258

    In addition you have to activate the MicroLIB checkbox in the "Options for Target" Window.
    Click image for larger version

Name:	OFT.PNG
Views:	0
Size:	25.5 KB
ID:	3259

    The easiest way is, using the TTY UART2 Example from the "pack installer":
    Click image for larger version

Name:	Pack_Inst.PNG
Views:	0
Size:	91.5 KB
ID:	3260

    Please check the Baud rate you are using.
    At 9600 Baud your Message will need min. 416s, 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.
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  3. #3
    New Member New Member Litun is on a distinguished road
    Join Date
    Aug 2017
    Posts
    26
    Points
    196.25
    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
    Last edited by Litun; Feb 2nd, 2018 at 12:50 AM.

  4. #4

    Infineon Employee
    Infineon Employee
    Mc-Key will become famous soon enough
    Join Date
    Jan 2018
    Location
    Germany
    Posts
    28
    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/Infine...5ba9870bd91373

    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.
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

+ Reply to Thread

Tags for this Thread

Disclaimer

All content and materials on this site are provided as is. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.