About the author

  • Aayush Vetwal

    In the description of Prescale Counter Register (PC) you’ve written “When PR reaches the value in PC , PR is reset back to 0 and Timer Counter is incremented by 1”. But it’s actually PC that resets back to zero when PC matches the PR value. This was the first online article I came across when I looked to study LPC214x Timer and it got me confused for a while. (Anyways, thankyou for the wonderful article.)

    • Hey Aayush! Thanks for notifying that sentence typo. πŸ™‚ I actually interchanged PC and PR lol … What I meant was : “When PC reaches the value in PR , PC is reset back to 0 and ..”. I’ve edited it now. Also .. I’m extremely sorry for the confusion. I’ve too gone through such confusions and know how it feels. I’m really glad you liked it. At least some1 is taking my tutorials seriously xD πŸ˜€ Also I’ll be posting an article on Interrupts in lpc214x next week just in case if anyone needs it.

  • OMKAR

    fine articles, good, your article helped me a lot thank you very much i am waiting your next article on interupt.

  • shruthi

    Thank you for this article,I was able to implement the timers in lpc2148 and create delays.

  • nilesh

    Sir I want to generate sine wave by using pwm using lpc2148 so please post the tutorial for pwm… waiting for your reply

    • Hi Nilesh , I am now working on lpc214x PWM tutorial , might take around 6 days for me to complete it. Uart Tutorial is also in pipeline πŸ™‚ After that planning to do on I2C and SPI.

      • Hi sir,

        thank you for the most easy way to understand tutorials πŸ™‚ i was waiting for the UART and I2C tutorials….

  • vijay_kumar

    Thnx for the tutorial on timers…..
    first i felt it was difficult to understand, but with your tutorial i felt it is very simple…
    thanx alot..
    There are protocols like CAN, I2C, and SPI. I wish u would give us the tutorials on these topics….

    • Thanks Vijay! πŸ˜€ I am planning to do tutorials on I2C and SPI after completing PWM and Uart tutorials which I’ve just started. I am working to post them as soon as I can πŸ™‚

  • jagdish

    hi umang.

    first of all thank you very much for these work.
    I am new to ARM, it helped me much and best of luck for your future work.

  • Dinu

    Its really a very good article… Its so simple to understand… Very much useful for beginners like me….

  • Dinu

    Really Gr8 article… Suitable for beginners like me… Keep on posting pls

  • anoop

    excellent work…..really gud for beginner…..

    • Thanks Anoop πŸ™‚ I start on UART and I2C articles soon.

  • anas

    dude, nice work bro….

  • Gopi M

    Fantastic article … this article will me a lot . thanks a lot … keep doing these thing …

  • jo

    Thank u .There are protocols like CAN, I2C, and SPI and also other features like uart wdt I wish u would give us the tutorials on these topics….

    • Hi , Will be doing ADC, I2C , SPI & Uart soon πŸ™‚

      • aru

        also i want to know how to use psp parallel slave port in pic16f877a

  • aru

    i have noticed some problem in your 1st code of led blinking using timer for generating the delay
    Actually at first the led will be ON till it reaches 0.5 second but after that it keeps on blinking though it has not reached 0.5 second.it should be like for 0.5second ON and 0.5second OFF.even i tried for 1sec delay by changing value 500 to 1000 but this is also not working

    • Hi aru , I guess I had resolved that bug , i’ll check it again and let you know. That bug has something to do with TC not getting reset properly. Also which Keil IDE Version are you using ?

      • aru

        i m using 4.1aversion .i got the solution check this code below, only 2 lines should be added.

        #include
        #define PLOCK 0x00000400

        void init_pll0()
        {
        PLL0CON = 0x01; //setup
        PLL0CFG = 0x24;

        PLL0FEED = 0xAA; //feedseq
        PLL0FEED = 0x55;

        while( !( PLL0STAT & PLOCK )); //connect
        PLL0CON = 0x03;

        PLL0FEED = 0xAA; //feedseq
        PLL0FEED = 0x55;

        VPBDIV = 0x01; // PCLK is same as CCLK i.e 60Mhz
        }

        void init_Timer0(void)
        {

        T0CTCR = 0x00;
        T0PR = 59999;
        T0TCR = 0x02; //Reset Timer
        }

        void delayMS(unsigned int milliseconds) //Using Timer0
        {
        T0TCR = 0x02; //Reset Timer
        T0TCR = 0x01; //Enable timer
        while(T0TC < milliseconds); T0TC=0X00; T0TCR = 0x00; //Disable timer } void main() { init_pll0(); //Initialize CPU and Peripheral Clocks @ 60Mhz init_Timer0(); //Initialize Timer0 IO0DIR = 0xFFFFFFFF; //Configure all pins on Port0 as Output PINSEL0=0x00; while(1) { IO0SET = 0xFFFFFFFF; //Turn on LEDs delayMS( 500); //0.5-Second(s) Delay IO0CLR = 0xFFFFFFFF; //Turn them off delayMS(500); } } now i require help in writing different code for each feature like capture,match(compare), pwm.also i want to know whether is it compulsory that when we use cature, pwm, match the timer should be in counter mode.

        • Vikas Thamke

          Actually delay we r getting is not 5 mSec, its 5 Seconds. if we pass argument of 500 in delayMS() function

    • Rajesh Kowsika

      me too have same prob..wat is the solution

  • santhosh

    superb job thanks a lot…..

  • santhosh

    hi,
    in timer program they defined some binary value for PLOCK..
    can anyone explain me the use of PLOCK..

    • thomas geroge

      PLOCK is Defined @ the beginning of program, as 0x400. check user manual for PLLSTAT register

  • Gopi M

    Hai

    I have a doubt regarding the machine cycle.

    In case of 8051(AT89C51) …. it take 12 machine cycle to execute single instruction

    In case of PIC 16F877A …. in take 4 machine cycle to execute single instruction

    but what about ARM LPC2148 …. how many machine cycle it will take to execute single instruction. ???????

    • Mahesh

      Gopi me too having same doubt if you know the answer reply me.

      and what are bits of TXTCR???why we are putting 0x01,0x02,and 0x00 is there any specific reason.

  • omkar

    thnax brother it was very usefull……
    could you post more tutorials on LPC2148….

  • Utpal

    Hi friend …
    i am not good programer but now i am starting for programing . acturly i want to take time(T0TC) in verialable and display on lcd.. i have lcd program.but how can i print this on lcd…SO CAN U HELP ME ?

    WHAT IS data type of T0TC ? and lcd requre charecter …

  • Vishnu chittan

    hi Umang Gajera
    I am waiting for your tutorial on capture.
    Please give me some hints to write c code for measuring the frequency of Square wave pulses.
    I want to measure the square wave freq in MHz using Capture in LPC2148 .

  • Balkrishn Tulsyan

    I am using uvision keil 4 and have written the same code what you have posted in this tutorial but Its showing identifier “T0CTCR” is unidentified. can u please solve this issue. i am using “ARMCC” compiler as shown in project properties.

    • Power_user_EX

      Hello Balkrishn, Please change the following line:
      #include
      to:
      #include

      The demo code is missing in the #include line. Will fix it soon πŸ™‚

  • Arnab Malakar

    Hello Umang Gajera…. thanks for the code….it really helpfull… but…i want to to that if i want change the delay time….where should i write?? for 500 ms what value to change ? In this code T0MR0 value is not given….
    in Proteus Simulation the delay is showing is 7.04us

  • ravi

    Hello Umang Gajera,this very good tutorial for bignners,lot of people learn from u r tutorials.will appreciate u r hard work ,we are requesting to give the tutorial on i2c and uart.
    when we can expect i2c and uart tutorial?

  • Angie Y

    Hello, i’m referring this code for LPC11xx controller,I’m trying to generate a low frequency from 9hz to 11hz[PWM],presently getting only one frequency i.e., constant of 9.5hz while varying match register MR3 and prescale register, i’m using LPC1115 controller[48pin], kindly suggest me how to proceed.

  • Priykant Ashara

    would you please give explanation for void initClocks(void) ?

Server monitoring / website monitoring with Livewatch.de
Server Monitoring with Livewatch.de