Slight Delay After Returning from Interrupt

前端 未结 2 2193
没有蜡笔的小新
没有蜡笔的小新 2020-12-20 06:12

I\'ve written a small program that uses a button on an STM32 Discovery board to act as a counter in either Binary/Decimal/Hexadecimal mode (screen cycles through the 3 optio

2条回答
  •  轮回少年
    2020-12-20 07:17

    Probably lcd_putint takes a lot of time to refresh the display. It probably convert each number to string and then put it to the screen. format_int() In binary case it loops 4 times, then 4 times more than Hex and Dec cases.

    If you change the code as below, It will, I guess, be faster:

    char bin[5];
    sprintf(bin, "%d%d%d%d", ((n&0x08)>>3), ((n&0x04)>>2), ((n&0x02)>>1), (n&0x01));
    lcd_putstring(bin);
    

    I know there are a lot of solutions to convert number to binary string, but the key point is to use lcd_putstring that is surely faster then call 4 times lcd_putint

提交回复
热议问题