mirror of
https://github.com/drasko/open-ameba.git
synced 2024-12-24 23:25:19 +00:00
fix clk cpu
This commit is contained in:
parent
affec14b99
commit
b976c62423
7 changed files with 4 additions and 4 deletions
|
@ -94,14 +94,14 @@ void wait_us(int us) { // До 2.147483648 секунды!
|
|||
uint32_t start;
|
||||
#ifdef WAIT_US_USE_CYCCNT
|
||||
if(us < 1) return;
|
||||
if (us < 255) { // G-timer resolution is ~31 us (1/32K), use DWT->CYCCNT...
|
||||
if (us < 327) { // G-timer resolution is ~31 us (1/32K), use DWT->CYCCNT...
|
||||
if(!(DWT->CTRL & DWT_CTRL_CYCCNTENA_Msk)) { // уже включен?
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; // открыть доступ
|
||||
DWT->CYCCNT = 0; // обнулить и запустить
|
||||
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; // запустить счет
|
||||
}
|
||||
start = DWT->CYCCNT + us * ( PLATFORM_CLOCK / 1000000 );
|
||||
while ( ( ( int32_t )DWT->CYCCNT - start) < 0 );
|
||||
start = DWT->CYCCNT + us * (PLATFORM_CLOCK / 1000000ul);
|
||||
while ((int32_t)(start - DWT->CYCCNT) > 0);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -246,6 +246,6 @@
|
|||
#if CPU__CLK_DIV5_3
|
||||
#define PLATFORM_CLOCK (200000000ul>>CPU_CLOCK_SEL_VALUE)
|
||||
#else
|
||||
#define PLATFORM_CLOCK (((200000000ul*5ul)/3ul)>>CPU_CLOCK_SEL_VALUE)
|
||||
#define PLATFORM_CLOCK (((200000000ul*5ul)/6ul)>>CPU_CLOCK_SEL_VALUE)
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue