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));
}

PIC32MZ tutorial -- Core Timer的更多相关文章

  1. PIC32MZ tutorial -- Watchdog Timer

    Watchdog is a very necessary module for embedded system. Someone said that embedded system operates ...

  2. PIC32MZ tutorial -- 32-bit Timer

    The microcontroller is PIC32MZ2048ECH144 on the PIC32MZ EC Starter Kit. This microcontroller has fou ...

  3. PIC32MZ tutorial -- OC Interrupt

    In my previous blog "PIC32MZ tutorial -- Output Compare", I shows how to apply Output Comp ...

  4. PIC32MZ tutorial -- External Interrupt

    In my older blog "PIC32MZ tutorial -- Key Debounce", I shows how to acheive key debounce w ...

  5. PIC32MZ tutorial -- Timer Interrupt

    An interrupt is an internal or external event that requires quick attention from the controller. The ...

  6. PIC32MZ tutorial -- Output Compare

    Output Compare is a powerful feature of embedded world. The PIC32 Output Compare module compares the ...

  7. PIC32MZ tutorial -- Input Capture

    Today I accomplish a simple application for PIC32MZ EC Starter Kit. This application uses Input Capt ...

  8. PIC32MZ tutorial -- Change Notification

    In my last post I implement "Key Debounce" with port polling, port polling is not very eff ...

  9. PIC32MZ tutorial -- Key Debounce

    Today I accomplish a application on PIC32MZ EC Starter Kit. The feature of application is to light u ...

随机推荐

  1. Hibernate的save()和persist()的区别

    hibernate之所以提供与save()功能几乎完全类似的persist()方法,一方面是为了照顾JPA的用法习惯.另一方面,save()和 persist()方法还有一个区别:使用 save() ...

  2. dw的流体网格布局

    在设计视图拖拽 在插入面板中选择插入流体网格布局标签 在对话框中如果不选中新建行复选框 如果总的列数是5列 一行的列宽和上一行的列宽加起来没有5列的话,下一行会上浮

  3. oracle数据库备份和还原

    ip导出方式:exp  demo/demo@127.0.0.1:1521/orcl file=f:\f.dmp full=y 备份:exp demo/demo@orcl file=f:\f.dmp f ...

  4. Java-接口和抽象类区别

    在类的设计中,需要明确一个原则,一个类不要去继承一个已经实现好的类,只能继承抽象类或实现接口,如果接口和抽象类都可以使用,那么优先使用接口,避免继承局限

  5. C++输入输出流格式控制

    来源:http://blog.csdn.net/virtualdesk/article/details/5355793 1.使用控制符控制输出格式 控制符 作用 dec 设置整数的基数为10 hex ...

  6. Centos 6.5 rsync+inotify 两台服务器文件实时同步

    rsync和inotify是什么我这里就不在介绍了,有专门的文章介绍这两个工具. 1.两台服务器IP地址分别为: 源服务器:192.168.1.2 目标服务器:192.168.1.3 @todo:从源 ...

  7. XFire最佳实践

    前言:XFire是新一代WebService框架,同时也支持与Spring集成,帮助我们方便快速地在Spring框架中开发WebService应用. 本节主要介绍XFire+Spring集成的2种常用 ...

  8. Play with docker 1.12

    Docker v1.12 brings in its integrated orchestration into docker engine. Starting with Docker 1.12, w ...

  9. Mybatis原理分析之一:从JDBC到Mybatis

    1.引言 本文主要讲解JDBC怎么演变到Mybatis的渐变过程,重点讲解了为什么要将JDBC封装成Mybaits这样一个持久层框架.再而论述Mybatis作为一个数据持久层框架本身有待改进之处. 2 ...

  10. c++智能指针实现方式1

    #include<iostream> using namespace std; // 定义仅由HasPtr类使用的U_Ptr类,用于封装使用计数和相关指针 // 这个类的所有成员都是pri ...