Jump to content

gfxSleepMilliseconds() stuck?


yaoyutaoTom

Recommended Posts

I  run the demo arcsectors. But the gfxSleepMilliseconds()  stuck.

here is my code

int main(void)
{        
    coord_t        width, height, r1, r2, cx, cy;
    uint8_t        sectors;
    
    SysTick_Config(SystemCoreClock / 1000);    
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);    
    lcd_init();    
    win_flash();    
    delay(1000);
    lcd_clear();
    
    gfxInit();
    
    // Get the screen size
    width = gdispGetWidth();
    height = gdispGetHeight();

    // Initialize some variables
    r1 = width > height ? height/3 : width/3;
    r2 = r1*3/4;
    cx = width/2;
    cy = height/2;
    sectors = 1;
    
    while(1) {
        // Draw the arc sectors
        gdispClear(White);
        gdispDrawArcSectors(cx, cy, r1, sectors, Black);
        gdispFillArcSectors(cx, cy, r2, sectors, Black);

        // Increase the sectors counter
        sectors++;

        // Waste some time
        gfxSleepMilliseconds(250);
    }
}




static volatile uint32_t gfx_tick = 0;
static volatile uint32_t cnt = 0;

systemticks_t gfxSystemTicks(void)
{
    return gfx_tick;
}
 
systemticks_t gfxMillisecondsToTicks(delaytime_t ms)
{
    return ms;
}


void SysTick_Handler(void)
{    

    gfx_tick ++;
    
    if (0 != cnt)
        cnt--;
}

extern void delay(uint16_t val)
{
    cnt = val;
    while(cnt);
}

if I replace the gfxSleepMilliseconds(250) with delay(250), it is OK. what is wrong with it ?

Edited by Joel Bodenmann
Using code box
Link to comment
Share on other sites

Hello @yaoyutaoTom and welcome to the µGFX community!

Can you please give us more information about the system that you're using:

  • What hardware (eg. what STM32)
  • Whether you're using an underlying RTOS or bare metal
  • Used compiler
  • What HAL you use (eg. CubeHAL?)
  • Anything else that might be helpful/important to know

In case of you're using the CubeHAL, just take the example from the wiki to implement the systick functions, there's not need to write that yourself: https://wiki.ugfx.io/index.php/BareMetal#Example
If you can't do that because you're not using CubeHAL but something different you might want to set a breakpoint at SysTick_Handler() to verify that it actually gets called.
Another likely cause is that you're using an older version of the µGFX library which contains a bug in the RAW32 port used to run on baremetal (which I assume you're doing). Try updating to the latest version. In general we recommend using the latest master branch from the Git repository, not just the latest stable release.

For everything else we need to have the information mentioned above.

P.S.: Please use code-boxes to put code in your posts, I added them this time for you.

Link to comment
Share on other sites

The StdPeriph library is very old and deprecated. You should really be using the CubeHAL instead (which is the official successor of the StdPeriph library).
But anyway, from the µGFX point of view this won't change anything.

Please do the two other things mentioned in my first post to further track down the problem (Using the debugger to check whether the systick handler gets called and using the latest git master version of the µGFX library).

Link to comment
Share on other sites

Using the Keil compiler with raw32 you are required to set GFX_CPU appropriately in your gfxconf.h file due to bugs in the Keil c runtime library.

You also need to use the latest master branch from the ugfx git repository in order to get some recent updates for the Keil compiler.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...