FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: EVE code CPU usage - is it safe to sleep()?  (Read 8659 times)

RafiRomero

  • Newbie
  • *
  • Posts: 2
    • View Profile
EVE code CPU usage - is it safe to sleep()?
« on: March 11, 2019, 11:54:42 AM »

I'm running the exported code from EVE Screen Designer (4.5 Beta 2) on a BeagleBoard running Linux (I've adapted some of the HAL).
It's running fine, but using 100% of the CPU, because FT_Esd_MainLoop is running a tight loop with no yield or sleep.
I am wondering if it is OK to add a sleep in the main loop?
If so, is there some constraint as to how often I need to let the main loop run, or does it just need to be fast enough to redraw the screen at the rate I require (so, 1Hz would probably be fine for my application, but I'll probably run it rather faster)?
I'm not using touch controls.
Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 892
    • View Profile
Re: EVE code CPU usage - is it safe to sleep()?
« Reply #1 on: March 11, 2019, 01:35:03 PM »

Hello,

I would suggest that if you are not using touch controls that it would be fine to add a Sleep to the main loop.
Adjusting for your desired refresh rate would be acceptable.

Best Regards,

FTDI Community
Logged

Kaetemi

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: EVE code CPU usage - is it safe to sleep()?
« Reply #2 on: March 12, 2019, 12:57:45 PM »

Generally it will be running tight loops where it waits for the co processor to finish. It'll be easiest to just put a 1ms sleep in those loops. You may also put the 1ms wait in the "Idle" function of your app instead, since that gets called during tight loops (Create an Idle slot under App.main, double click to go to user code, and put in the sleep code).

The main loop builds a new display list for each frame, which is necessary for animating widgets. Ideally the render portion of the loop will be called at the same rate as the frame rate.

An alternative could be to do a blocking wait on the main thread, instead of spinning the thread, and make use of the interrupt output pin of the EVE chip to resume the thread, but that may involve some platform specific code.
Logged

RafiRomero

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: EVE code CPU usage - is it safe to sleep()?
« Reply #3 on: March 14, 2019, 10:43:46 AM »

That's great, thanks for your fast and extremely informative answers!
Logged