RIT usage of LPC1768

Publisher:qpb1234Latest update time:2017-01-12 Source: eefocusKeywords:lpc1768 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In addition to the system tick timer and the general timer, LPC1768 also introduces a timer called the repetitive timer RIT. This timer can only be used for timing operations and has an interrupt. I personally feel that this seems to be a timer designed for delay functions.

So what process is followed when using this timer?

First, turn on the clock

 

Second, we need to determine the timer's frequency division value from pclk, which depends on another register

 

Third, turn off the timer first

 

Fourth set register comparison value

 

Fifth, clear or mask some specific comparison mask bits

 

Finally, turn on the interrupt and start the timer

#define RIT_INT_POSITION 0

#define RIT_ENCLR_POSITION 1

#define RIT_ENBR_POSITION 2

#define RIT_EN_POSITION 3

 

void RitInit(u32 count)

{

    LPC_SC->PCONP |=(1<<16); //Turn on the clock sys, divide by four to 25M

    LPC_RIT->RICTRL &= ~(1<<3);

    LPC_RIT->RICOMPVAL = count;

// LPC_RIT->RIMASK = count;

    LPC_RIT->RIMASK = 0x80000000;

    LPC_RIT->RICOUNTER = 0;

    NVIC_EnableIRQ(RIT_IRQn); /* enable irq in nvic */

    LPC_RIT->RICTRL = (1<

}

 

Finally, we need to respond to the interrupt in rit's interrupt function, as follows

void RIT_IRQHandler()

{

    u8 state = LPC_RIT->RICTRL;

    if(state&0x01) //An interrupt occurs

    {

        RitStop();

        LPC_RIT->RICOUNTER = 0;

        LPC_RIT->RICTRL |= 0x01; // Clear interrupt

        RIT_INT_CALLBACK;

        RitStart();

    }

}


Keywords:lpc1768 Reference address:RIT usage of LPC1768

Previous article:SPI communication of LPC1768
Next article:LPC1768 serial port usage

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号