PIC32MZ tutorial -- Core Timer

it2022-05-09  22

PIC32MZ tutorial -- Core Timer

  Core Timer is a very popular feature of PIC32 since it is a piece of the MIPS M4K core itself and is common to all MIPS processors. Most RTOS's timer are based on core timer. This timer has a fixed prescaler 1:2, and it is a 32-bit timer, no need to combine with two 16-bit timer like we do with other timers (Timer2 and Timer3 or Timer4 and Timer5). At this moment I only use core timer to implement time delay. To accomplish it, I write two functions: ReadCoreTimer() and CoreT_DelayMs().

  

unsigned int __attribute__((nomips16)) ReadCoreTimer(void) { unsigned int timer; // get the count reg asm volatile("mfc0 %0, $9" : "=r"(timer)); return timer; } void CoreT_DelayMs(unsigned int delayMs) { unsigned int delayStart; delayStart = ReadCoreTimer(); while ((ReadCoreTimer() - delayStart) < (delayMs * CORE_TIMER_MILLISECONDS)); }

 

posted on 2016-01-31 14:00 GeekyGeek 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/geekygeek/p/pic32mz_coretimer.html


最新回复(0)