infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 22

Thread: Get current system clock time

  1. #11
    Intermediate Intermediate Pirate02 is on a distinguished road
    Join Date
    Jun 2019
    Posts
    11
    Points
    250
    Thank you so much for your help HIGHTEC.henk-piet.glas. I have a another problem because I try to use clock_t on the LCDdemo example but it return the the value 0.

    Code:
    t0 = clock();
    
    //my function
    Delay(5000);
    
    t1 = clock();
    
    dt = 1.0*(t1-t0)/SYSTIME_CLOCK;

    I attached my project to facilitate the comprehension of my problem. So in the source file LcdDemo.c I declared t0 and t1 between the Delay(5000) and normally the output of dt have to be a value different of 0.I checked the values of t0 and t1 and both take the value 0, I don't know why ? (maybe because de library is not recognized).

    Thank you in advance.
    Last edited by Pirate02; Jul 11th, 2019 at 03:02 AM.

  2. #12
    Intermediate Intermediate HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017
    Posts
    102
    Points
    1997.5

    Hi Pirathap,

    Looking at your project I think you need to make the following changes:
    1. Times.c contains both an external reference and a declaration of variable TimeInTicks. You must comment out the declaration because the actual variable is defined in LcdDemo.c.
    2. In LcdDemo.c you must remove the static keyword from the declaration of TimeInTicks.
    3. Also in this module replace the double-type of variable dt with clock_t.
    4. In main drop the 1.0 floating point constant from the dt assignment. So in this case I'm purposely dropping the remainder.
    5. In the printf statement you may cast dt to an integer.
    After these modifications I expect it will work as intended. The printf statement should print a 5 second delay.

    Henk-Piet Glas
    Principal Technical Specialist
    Embedded Software

  3. #13
    Intermediate Intermediate Pirate02 is on a distinguished road
    Join Date
    Jun 2019
    Posts
    11
    Points
    250

    Execution time measurement of a function on TC275 Application kit

    Thank you for your reactivity, your solution work well. I have a last question, how can I have the exact CPU time with the function clock() because now I have a output only in second (0 to 60) and not the exact CPU time from the beggining to the end of a small program.

    I think this solution should be the good one :

    Code:
    #define SYSTIME_CLOCK	1000	/* timer event rate [Hz] */
    
    
    t0 = clock();
    
    	//my function
    
    	int i=0;
    
    		Delay(1);
    
    	t1 = clock();
    
    	dt = (t1-t0)*1000 /CLOCKS_PER_SEC;
    	dt = (float)dt;
    But when the program is executed very quickly (under a second), It show me '0'.
    (How can I retrieve the size in memory that take my function in the board ? Address calculation ?)
    ?????
    Last edited by Pirate02; Jul 12th, 2019 at 03:02 AM.

  4. #14
    Intermediate Intermediate HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017
    Posts
    102
    Points
    1997.5

    Hi Pirathap,

    I think you were well under way with the snippet of code that you included. The problem is most likely caused by the "%d s" format string. Since you changed the type of dt to double you'd have to use a double or float format specifier instead, for example "%3.0f milliseconds". I expect that in that case it will work.

    But using a double for dt is perhaps a bit too expensive. You might want to stick to a clock_t type. For example, the following should work. First, at the top of LcdDemo.c add the following macro:

    Code:
    #define SCALE_MICRO_SECONDS(seconds) ((seconds)*((clock_t)1e6))
    Next make sure dt is of clock_t type. Then for dt use the following assignment:

    Code:
    dt = SCALE_MICRO_SECONDS(t1-t0)/SYSTIME_CLOCK;
    And proceed to print the result as before:

    Code:
    usr_sprintf("Milliseconds: %lu\n",(unsigned long)dt);
    Given these conditions a Delay(1) should result in 1000 us.

    Best regards,

    Henk-Piet Glas

    Principal Technical Specialist
    Embedded Software

  5. #15
    Intermediate Intermediate Pirate02 is on a distinguished road
    Join Date
    Jun 2019
    Posts
    11
    Points
    250

    Retrieve the memory size of the function and send it to the PC

    Hello HIGHTEC.henk-piet.glas, thank you for your help, I manage to make the same thing with the time_t librairy so thanks for your support. From few days I try to get the size that take this function on the memory during the execution on the board. After to retrieve the time measurement and the memory size information to my desktop PC (I try to search a solution to transfer these informations from the board to the PC by the USB connection but I don't find anything in the forum).

    Do you have a solution ?
    Thanks in advance
    Last edited by Pirate02; Jul 16th, 2019 at 12:56 AM.

  6. #16
    Intermediate Intermediate HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017
    Posts
    102
    Points
    1997.5

    Hi Pirathap,

    You can consider using simulated IO as I demonstrated in this example. Here I added the PLS simulated IO routines. These same routines allow you to create a file on your host OS as well. Of course such a solution creates a tethered dependency on the debugger so it really depends on whether you want to be able to do this in the field, or just during debugging.

    As for the size of your function, I suppose you're referring to the amount of code it consumes. For this you can use the map file of your project. You'd need to enable the -ffunction-sections in the Code Generation tab of your compiler options. This mangles the function name into the default section name. So function main for example is (then) mangled into a section called .text.main. You can then easily lookup this section name into your map file and determine its code size.

    Best regards,

    Henk-Piet Glas

    Principal Technical Specialist
    Embedded Software

  7. #17
    Intermediate Intermediate Pirate02 is on a distinguished road
    Join Date
    Jun 2019
    Posts
    11
    Points
    250

    Retrieve information from the board to the PC

    Hello, thank you for your reply Henk-Piet Glas

    I see the example that you show but I don't see understand where is the PLS simulated IO routines. Because I want to send the information that I executed from the board to the PC only by the USB connection and save the information in a txt file on the PC.

    Also,do you think that is possible to retrieve the adresses that I have in the map file directly in the code (if you have a example with the start and the end adress of the main for example) ?

    Best regards,

    Pirate02
    Last edited by Pirate02; Jul 17th, 2019 at 03:15 AM.

  8. #18
    Intermediate Intermediate HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017
    Posts
    102
    Points
    1997.5

    Hi Pirathap,

    I have attached an example that demonstrates simulated IO. I have not been able to test it on real hardware because I haven't got it on me right now. But it should work. It should create a file called simio.out containing the following content:

    Code:
    _lc_b_main := 0x80000412
    _lc_e_main := 0x80000468
    Defining the start and end labels of main. You will need to replace the user name glas with the username that you have yourself on your OS. If it doesn't work then I'll need to give this another look tomorrow.

    Best regards,

    Henk-Piet Glas

    Principal Technical Specialist
    Embedded Software
    ?????

  9. #19
    Intermediate Intermediate Pirate02 is on a distinguished road
    Join Date
    Jun 2019
    Posts
    11
    Points
    250

    Retrieve the value of a variable on PC from TC275

    Hello henk-piet.glas thank you for you reply. I tested the code that you show me and I included it to my project. The problem is that I don't have any error during the compilation but the function don't create any file on my PC in the path that I specified.

    In the attached zip you'll find in the file LCDDemo.c the main() where I display the execution time of my code on the GLCD of the board (this part is operational) and after I try to create the file by specified path with the replacement of "glas" by my personal username on W10 to write the information that I have on the GLCD in the file on my PC.

    And finally, I want to retrieve the amount of my function in the memory of the card (retrieve the start and end adress of Delay(5000) but in the future it will be a another different function so I have to retrieve the start and end adress dynamically in this section of the code).

    (The information written in the file is retrieve after the execution on the board ? Maybe I can use the ASC0 transmission ?)

    Thank you in advance.
    Last edited by Pirate02; Jul 18th, 2019 at 05:49 AM.

  10. #20
    Intermediate Intermediate HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017
    Posts
    102
    Points
    1997.5

    Hi Pirathap,

    Have a look at the attached example, and recording. The recording has a limited lifetime. It will expire a week from now. Use Blomkamp as a password to access it.

    Within the example, note tiny function nill. From this function I calculate the start and end address in linker script solution.ld. I do this by means of labels _lc_b_nill and _lc_e_nill. These are assigned with the current location pointer and can subsequently be accessed as labels within your application. The labels are printed to stdout. I did this because we only support stdin, stdout and stderr. Host file IO isn't supported at this point.

    The recording shows the simulated IO windows. I access its properties and then grab the contents of stdout and redirect it to a file that I store on the desktop. Note that stdout appears on the simulated IO window and also note that a file is created on the desktop containing the same content.

    Best regards,

    Henk-Piet Glas

    Principal Technical Specialist
    Embedded Software
    ?????

+ 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.