About the author

  • Arun Kolte

    nice explaination . excellent for beginners

  • Jayaraj

    Hi Power_user_ex,

    I just got started with lpc2148 mC and found your article very useful. Thanks man. In fact by seeing other post on the internet, i was actually doubt full whether i can study it or not. But after when i saw your post, i understood clearly.
    To acknowledge and to mention, the basic needed tutorial for this, the c shift operator tutorial, you hosted as a separate link was awesome. Great man. Good idea of first identifying the basics and then diving into the core logic is great. Thanks once again.

    Just wanted to acknowledge for your brilliant effort.
    Good work.

    • Thanks Jayaraj! Your feedback has motivated me to add more tutorials relating to embedded stuff. I’ll try my best to keep things clear and would like to know your suggestions if you have any 🙂 At present I am working on LPC1768 MCU so will add tutorials for that too. Planning to make some of my projects open source. Stay in touch for more 🙂

      -Regards ,
      Power_user_EX

  • Jayaraj

    Hi Power_user_ex,

    If possible, can you just write a tutorial on lpc2148 programming with lcd (16 x 2). I looked at some sample code but couldn’t understand anything. So, can you just post an lcd programming tutorial for the same.
    Kindly post.
    Awaiting for your post.
    Thanking you.

  • shrikant

    Sir,
    i want to know how to deal with lpc2148 timers and getting interrupts from them after a match is found……

  • Neha

    Hi Power_user_ex,
    Your tutorials are really nice.It helped me a lot.
    Thank you………

  • Virang

    Thanks a lot sir !!!
    this proved really helpful !!!

  • bhavya

    hii arun currently i would like to work on timers in LPC2148 can please help me how to work on timers

    • Hi Bhavya , this is Umang. I will be posting a tutorial on Timers in LPC2148. If you need any kind of help in embedded or lpc2148 you can post your query in embedded section on our forums @ http://www.ocfreaks.com/forums/

  • sameer

    hi i want to interface 16×2 lcd with lpc2148. could u pls tell me wat changes should i make in lpc214x.h program to change the port 0 to output port?

    • Working on 16×2 LCD interfacing article now 🙂

  • Anand

    Great article!

    Guess what! Today is my first day in learning embedded stuff and I came across this article on my first day itself and that too I am learning on LPC2148 from NGX.

    Please post more articles.

    Thank you so much.

    • Welcome Anand … more articles relating to Timers , PWMs , Uarts , LCD interfacing , etc.. are in pipeline.

      • Anand

        Please post an article related to interrupt covering FIQ, Vectored IRQ, non-vectored IRQ, SW interrupt. I am stuck with interrupt programming. Though I have done the same GPIO programs using interrupt, but still have to cover FIQ and SW interrupt.

        Thank you.

  • sbnull

    Thank you for the tutorial. It was a good point for getting started on lpc2148.
    But a question about IOxSET and IOxCLR, if writing 0s do not affect output, then instead of
    IO0SET |= (1<<30);
    and
    IO0CLR |= (1<<30);
    cant we use
    IO0SET = (1<<30);
    and
    IO0CLR = (1<<30);
    Thank you and more LPC2148 tutorials please.

    • Yes you are correct … Its only in the case of IOxPIN that we must using ORing , ANDing , etc.. so that other bits are not effected. I’ll update the tutorial. Thanks! Also I’ve posted a new tutorial on interfacing 16×2 LCD module with LPC2148 @ http://www.ocfreaks.com/interfacing-16×2-lcd-with-lpc2148-tutorial/

    • Anand

      Thank you for this info. I too have been following the same trend i.e IOxSET |= (1<<Y).

  • Embdd

    Hi Power_user_EX!

    This tutorial is AWESOME! THANK YOU SOOOOO MUCH! I have experience with PIC16F887 in assembly language, and when I faced the LPC2148 I was hopeless, I thought that it might be a problem to learn the tricks. But then I found your tutorials, THANK YOU FOR THE GREAT JOB YOU DID! They are great for beginners with LPC, beginners just like me.

    Cheers! Thanks again!

  • AditiR

    We had almost given up working on LPC 2148 for our project at 2am last night.

    And then we found this page.
    Thanks a ton. Finely written and explained. More articles awaited!

  • yogesh

    I WANT TO SENSE LOGIC HIGH FOR LPC2148 HOW CAN I SENSE IT.
    I HAVE MADE P0.4 AS INPUT
    LIKE IODIR0&=~(1<<4);
    if(IOPIN0 & (1<<4))
    {

    }
    BUT WHEN I AM SENSING INPUT 'HIGH' FROM OUTSIDE THE BOARD WITH COMMAN GND IT WILL MAKE THAT HIGH LOGIC TO GND. WHATS THE PROBLEM?
    PLZ RPLY..THANKS

    • Hi Yogesh!

      If you want to sense logic level at any pin you need to continuously scan that particular pin using a simple while loop. A more better way of doing this is to setup Pins like EINT0 to trigger an interrupt when the logic level changes say.. from Low to high. I will write a simple code for that and will attach it in my upcoming “LPC214x Interrupt Tutorial” .. which will be posted next. In the mean while you can try this code :
      [cc lang=”c” width=”400″]
      IODIR0&=~(1<<4); while(1) { if(IOPIN0 & (1<<4)) { IOSET0 = 0x1; //Set P0.0 To high when Logic High is sensed on P0.4 } } [/cc] If you need any other help regarding embedded stuff you can post a thread in embedded section of our forums.

      • yogesh

        thanks..

      • knbr

        why you are making 4th pin high in the if condition??
        why not you are using this below condition?
        if(IOPIN0==0x0)

  • yogesh

    CAN I USE TRANSISTOR FOR SENSING INPUT FROM OUTSIDE .AND COLLECTOR OF IT TO IO PORT OF ARM.WITH COLLECTOR VOLTAGE OF 3.3V. WILL IT WORK?
    RPLY THANKS

  • iris

    how to write hexcode for lpc2148 to read data from external source

    • Hi iris , did you mean you want to read status of GPIO pins configured as input or communication protocols like I2C , Uart , etc .. ?

  • Arfath

    Hi, I found your article really helpful. Can u plz write an article regarding PWM register settings and how to use them in lpc2148. Thank u.

    • Hi Arfath , I am working on PWM tutorial currently. Will post once I’m ready with it 🙂

  • madhu agrawal

    sir plezz show the next lec.

    • Yes.. working on more Lpc214x and Lpc176x tutorials 🙂 and .. I’m not Sir xD .. I’m Umang 🙂

  • rijan

    your posts and explanation has helped me a lot on getting started with Lpc2148.
    could you explain more on using the timers with more examples.

    • Hi rijan , My tutorial on timers is @ http://www.ocfreaks.com/lpc2148-timer-tutorial/ . Let me know what kind of examples you want .. I’ll try my best to cover those. 🙂

    • Hello rijan , It would be great you can suggest some examples. I’ll try to cover them in a different post may be. I’ve recently posted a tutorial on lpc2148 interrupts in which I’ve used a different timer example in Case #2 which uses like 3 match registers and all of them are configured to generate interrupts. I guess you must have a look at it 🙂

      -Regards

  • GK13

    Hi,
    Your tutorials are really nice and very helpful. It helped me a lot.
    Thank you………

  • Suresh

    Great stuff, thanks for sharing with explanations — sharing is knowledge.
    i will try to apply those on my new unplanned purchased project with vison that given by you.

  • BISH

    it simply awesome….got sme nic tips for programming..1000LIKE

    • Thanks a lot BISH 😀 That keeps us motivated!

  • Abhijeet

    Beautifully explained. Got the concept of GPIO very well.
    Please post more tutorials for basic interfacing…Keep it up…..

  • linus

    Hi,

    I tried dumping your example #5 onto a development board(MCB2140 with LPC2148) ….But the LEDs are not blinking…do I have to modify anything in the program…..

    • Hi Linus , make sure that you are running at 60Mhz and LED connections are as shown in the figure. Try to Run a Simulation in Debug Mode and check the PLL configuration , Clock speeds , and GPIO status. If its still not working do let me know.

  • NaseemH

    I’m taking a course in the embedded systems and today was the first lecture. I did understand a bit what was going on there, but not that much. And now after reading your article it seems much clearer, you do sir explain things pretty well.
    I have a question now 🙂
    is there a way I could get my hands on a LPC2148 board ?
    if not, is there a simulator at least that I could download and run tests on it?

    Thank you
    Naseem

    • Hi Naseem , KEIL UV4 IDE comes with a simulator – you can download it from http://www.keil.com . First go to “Target Options->Debug” and select the radio button which says “Use Simulator” (by default when you make a new project this is enabled). Next .. after compiling your code hit “Debug->Start/Stop Debug Session” and then press F5 to start the simulation. Your can check the status of your peripherals like GPIO , Timer ,etc.. by hitting “Peripherals” under main menu. Hope this helps.
      -Regards

  • praveen

    very well designed tutorial…….it really helped
    thanks :d

  • Shanmugam

    Hi Dude!
    Really an awesome tutorial… very kind of you… try to post tutorials on LPC1788 too.. I need it urgently…pls.Thanks

    • HI Shanmugam .. thanks dude! 🙂 I m having a lpc1768 board but tutorials might take bit time since I am busy with a few projects atm. If you need ny specific help with lpc1768 please post your query in forums under this section : http://www.ocfreaks.com/forums/f93/ and I’ll try to help you as soon as I can.

      -Regards

  • Gopi M

    i met a problem in the mentioned switch program (example 6 )
    . if i just copy that program and run in my development board, it work properly but in case .if i change the PIN configure in that program, i didn’t get the output.

    i just replace 7 by 1 pin and 30 pin by 0 th pin . i this case i didn’t get output.

    please clarify this doubt ….

    #include

    int main(void)
    {
    IO0DIR &= ~((1<<1)) ;
    IO0DIR |= (1<<0);
    while(1)
    {
    if((IO0PIN & (1<<1)))
    {
    IO0SET |= (1<<0);
    }
    else

    {

    IO0CLR |= (1<<0);

    }

    }

    }

    • Hey Gopi M, really sorry for the late reply .. was out of town for a few days.

      In your modified code you must need to change “if((IO0PIN & (1<<1)))" to "if( !(IO0PIN & (1<<1)) )" since we are sensing for a Low input for pin P0.1

      • Gopi M

        thank u so much Umang Gajera. i must mention that, u are doing a great work. many people are clear their doubt and learn more, so do these kind of things as much as possible.

  • Gopi M

    i have another one doubt in example 6

    while configure the 30 pin port 0 as output u using OR ( | ) operator, reason for that is , the other pin won’t get affected but in case of configure P0.7 as input u using AND ( & ) operator , in this case why con’t we use OR operator. is there any specific reason for using AND gate ??????

    clarify my doubt …

  • Gopi M

    Hai umang gajera ,

    i have a doubt. what is the difference between LPC2148 and LPC2138.
    is there any major difference…. then what is the thing, that made u to choose the controller LPC2148 @ umang gajera, why don’t u choose any other controller like LPC2138 and LPC2129, what is advantage of LPC2148 rather than other controller.

    Clear my Doubt ……….

  • Dinu

    Hey its really superb work…. You are doing a gr8 job… Keep it up… It wiil be very useful for beginners like me… Once again thanks…

    • Thanks Dinu! Stick around with us 🙂 will be posting more tutorials soon 😀

  • Dinu

    Can anybody show me how to declare a macro for the port 0 and a single port pin (eg: P0.0)

    • Hi Dinu , you want to use those macros to be used as placeholders or to assign/set values to the particular pin too ?

      May be something like “PORT0 = SET_HIGH(PIN5);” ? or you are looking for something else ?

      It would be better if we could discuss the possible solutions on our forums under this category : http://www.ocfreaks.com/forums/f93/

      -Regards

  • vikas goyal

    hey umang,

    thanx for such a nice explanation. in your example #6 you use external ground to sense the logic(0) at pin 0.7 and then makes pin 0.30 high to glow led. i am writing 4*4 keypad code. is it possible to make 0.30 pin logic(0) as output and connected it to pin 0.7 (initially logic(1) input) via switch and sense 0.7 pin to go to logic (0) after pressing the switch.??

  • harsha

    i want a c code for lpc2148 to interface to enc28j60 to make
    ethernet communication

  • vijay

    Sir,
    Try Some STM32F100xx Microcontroller Tutorials.. Its not available in this website.
    I want to get UART, I2C,SPI access for both STM32F100xx and LPC23xx

  • Abhay

    hello
    I am using PWM in lpc2148 but i got one problem when i try to modify PWM pin .it is not changing it still sends the old pulses in same program..please help me

    • Hi Abhay , I am really sorry for my late reply. How are you modifying the PWM pin ?

  • sindhu

    hi,

    if i have to program with multiple switches means whats the code..

  • sindhu

    This is the code what i wrote to blink the multiple leds by pressing multiple switches but whats the problem is…… am getting output only for the last led when that appropriate switch is pressed.

    can anybody tell me a solution for this ?

    #include
    int main(void)
    {
    IO0DIR =0x00000000 ;
    IO1DIR =0xFFFFFFFF ;

    while(1)
    {

    if( !(IO0PIN & (1<<14) ))
    {
    IO1SET |= (1<<25);
    }

    if( !(IO0PIN & (1<<15) ))
    {
    IO1SET |= (1<<26);
    }

    if( !(IO0PIN & (1<<16) ))

    {

    IO1SET |= (1<<27);
    }

    if( !(IO0PIN & (1<<17) ))

    {

    IO1SET |= (1<<28);

    }

    else

    {

    IO1CLR =0xFFFFFFFF ;

    }
    }

  • Muniyan

    Sindhu please do this code i wrote this in keil and execute in proteus it well works your code is correct but you use else if instead of i
    #include
    void delay()
    {
    int i;
    for(i=0;i<200;i++);
    }
    int main(void)
    {
    IODIR0 =0x00000000 ;
    IODIR1 =0xFFFFFFFF ;

    while(1)
    {

    if( !(IOPIN0 & (1<<14) ))
    {
    IOSET1 |= (1<<25);
    }

    else if( !(IOPIN0 & (1<<15) ))
    {
    IOSET1 |= (1<<26);
    }

    else if( !(IOPIN0 & (1<<16) ))

    {

    IOSET1 |= (1<<27);
    }

    else if( !(IOPIN0 & (1<<17) ))

    {

    IOSET1 |= (1<<28);

    }

    else

    {
    IOCLR1 =0xFFFFFFFF ;
    }
    }
    }

  • i m beginner of lpc1768 .so i cant understand user manual of lpc1768,pls help me how to write the program in lpc1768 ………..please explain with simple test program ……………..

    • Ravisankar

      Dear Mr. Prabhu,

      The best way to start LPC1768 programming is to, carefully going through the code bundle provided. Moreover it is a coretexM3 core, so you need to have a good understanding of data structures or at least structures and user defined data types(typedef) in C. ( you will understand what I mean if you open the code bundle.)

      If you want a jump start, here is my code to blink the LED connected to pin4 of port1. Since it is a software delay you can not expect same frequency all the time (if you connect the port pin to CRO/DSO)

      This code is written and tested in Keil 4.73

      #include

      unsigned int i, j, c=0;

      int delay (void){

      for(i=500; i!=0; i–)
      {
      for(j=100; j!=0; j–)

      c++;

      }
      return 0;
      }

      int main (void){

      LPC_GPIO1 ->FIODIR |= (1<FIOSET |= (1<FIOCLR |= (1<<4);

      delay();

      }
      }

      Hope this will help you to start your programming with LPC1768. Happy programming.

  • Ravisankar

    #include

    unsigned int i, j, c=0;

    int delay (void){

    for(i=50; i!=0; i–){

    for(j=10; j!=0; j–)

    c++;
    }

    return 0;

    }

    int main (void){

    LPC_GPIO1 -> FIODIR |= (1< FIOSET |= (1< FIOCLR |= (1<<4);

    delay();
    }
    }

  • Ravisankar

    Mr. Prabhu,

    There is a problem in the editor of the blog. I could not upload it correctly. However you can request me sending a mail. ravisankar.drm@gmail.com

    I tried twice to correct the mistakes in the code.

    bye