". Net Micro Framework portingkit–12" Systick Drive development

Source: Internet
Author: User
Tags sleep function volatile

Systick drivers are important for TINYCLR, the. Net Micro framework systems are multi-threaded and multitasking (single task multithreading for managed code, but there are tasks that run concurrently with managed code, such as we ping with the Mfdeploy program TINYCLR or erase Flash, is the other task in the execution) is to rely on it to achieve.

Systick Drive has three functions, one is what we call multitasking and multithreading support, the second is to obtain the system's current tick, so as to achieve delay waiting, such as our common events_waitforevents function depends on it to achieve the delay function Three is to provide two versions of the sleep function for native code.

Compared with ARM7 or ARM9, the CORTEX-M3 series of CPUs provide systick this feature, so we do not need to use a timer to simulate the function of the tick, directly with the system to provide systick on it. CORTEX-M3 Systick Its timer count is decremented, descending to 0 will trigger the interrupt (of course to make the Tickint), and then automatically load the value of the load register, start the next counting loop.

The load register can be filled with the maximum value of 0X00FFFFFF, for the 72M CPU, there will be about 250 milliseconds of delay. Because the value of the VAL register is decremented, it is worth noting in the porting of related code that the value of the tick in our concept should be (load-val).

Add the following code in the CortexM3.h file to facilitate configuration of the Systick registers.

struct CortexM3_SysTick
{
     static const UINT32 c_Base = 0xE000E010;
     /****/ volatile UINT32 CTRL; //0xE000E010
     static const    UINT32 CTRL_COUNTFLAG= ((UINT32)0x00010000);
     static const    UINT32 CTRL_CLKSOURCE= ((UINT32)0x00000004);
     static const    UINT32 CTRL_TICKINT= ((UINT32)0x00000002);
     static const    UINT32 CTRL_ENABLE= ((UINT32)0x00000001);
     /****/ volatile UINT32 LOAD; //0xE000E014
     static const    UINT32 LOAD_RELOAD= ((UINT32)0x00FFFFFF);
     /****/ volatile UINT32 VAL; //0xE000E018
     static const    UINT32 VAL_CURRENT= ((UINT32)0x00FFFFFF);
     /****/ volatile UINT32 CALIB; //0xE000E01C
     static const    UINT32 CALIB_NOREF= ((UINT32)0x80000000);
     static const    UINT32 CALIB_SKEW= ((UINT32)0x40000000);
     static const    UINT32 CALIB_TENMS= ((UINT32)0x00FFFFFF);
};

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.