This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LEARN DRIVERS

Hello friends,
I am new to ARM,and i want to learn how to write driver for a program that too in LPC2378.

void driver()
{ PINSEL4=0X00000000; PINMODE4=0X00000002; FIO2DIR=0X000000FF; FIO2PIN=0X00000000; RTC_PREINT=0X0000016E; RTC_PREFRAC=0X00006500; PCONP = 0X00000200; RTC_SEC = 0X00000000; RTC_MIN = 0X00000000; RTC_HOUR = 0X00000000; RTC_CCR = 0X00000001;

This is one of the example for Real Time Clock.I want to learn how to configure drivers for any other peripherals like LED,UARTS,etc.I have referred user manual as well as my LPC2378 data sheet but m not able to get the proper idea.

Thanks.

  • Real Time Clock

    Really? Where are the comments to indicate that? and posting brackets? you won't get very far like this. Read the user manual and study examples to start.

  • The RTC in the processor do not require any changes to pin modes, directions etc.

    By the way: Make sure you look in the user manual and not the datasheet for the processor. The datasheet contains no description of how to use the peripherials. It describes currents, voltages, temperatures, timing etc. It's the user manual that describes registers, configuration bits, operating modes etc.

  • A key skill required for learning this stuff is the ability to read & study - and put into practice what you find.

    You could start with the instructions on how to post source code: www.danlhenry.com/.../keil_code.png

  • THANKS FOR SUGGESTIONS,
    SAY IF I WANT TO WRITE DRIVERS FOR LED ANDWHAT WOULD BE THE STEPS TO WRITE.
    TILL NOW I HAVE GOT SOME IDEA,BUT M CONFUSED.

    THANKS.

  • void driver()
    {
            PINSEL4=0X00000000;
            PINMODE4=0X00000002;
            FIO2DIR=0X000000FF;
            FIO2PIN=0X00000000;
            RTC_PREINT=0X0000016E;
            RTC_PREFRAC=0X00006500;
            PCONP = 0X00000200;
            RTC_SEC = 0X00000000;
            RTC_MIN = 0X00000000;
            RTC_HOUR = 0X00000000;
            RTC_CCR = 0X00000001;
    }
    


    THANKS ANDREW,
    MY DOUBT IS HOW COME WE KNOW TO SELECT PINSEL4 NOT OTHER PINSEL(S),WHICH PORT PIN TO SELECT.
    I HAVE GONE THROUGH DATA SHEET,STILL IT IS NOT CLEARED.

    THANKS.

  • SO FAR YOU HAVE CLEARED ONE DOUBT REGARDING WHEN TO GO FOR DATASHEET AND WHEN FOR USER MANUAL.
    SAY IF I WANT TO WRITE DRIVERS FOR LED,AND THAT TOO BLINK LEDs ALTERNATELY WHAT WOULD BE MY FIRST STEP OF GOING THROUGH IN THE USER MANUAL.

    THANKS.

  • Stop going through the datasheet and look at the chip user manual instead.

    Stop screaming and locate the caps-lock button to the left on your keyboard.

    Stop posting random source code sequences with meaningless lines of register assignments, without any comments about what the assignment is intended to do.

    PINSELx registers each covers 16 I/O pins. So you should of course be able to document what changes you want to do to that register to get the specific result for that set of 16 pins.

    Same goes for PINMODEx registers.

    FIOxDIR and FIO2PIN registers covers 32 GPIO pins. So same there. What do you think happen when you assign 0x000000FF (=255) to FIO2DIR? The user manual tells you what it means to the processor. The schematics for your board tells you what the affected pins are connected to. The source comment should describe this together with the assign, so that a reader knows without having to retrieve the processor user manual and the development board schematics.

    Same thing for all other registers you seem to like to play with - or that you copy/pasted assigns to from somewhere else.

    Read the documentation. What is the meaning of every single bit of these registers? So what happens? Then you know what these lines do.

    For all other registers? First decide what you want to happen. Then read through the user manual and find out relevant registers. Read the documentation for the individual bits and decide what assigns you need to do to get the result you wanted. There are no simpler route. You just have to care for the details. The processor does. So when you give wrong details to the processor, you will get a different result than intended.

  • Thanks P.Westermark,
    I have selected one example for blinking the LEDs on ARM LPC2378,alternately.
    For that please suggest me what would be my first step as soon as i open the user manual documents.

  • "For that please suggest me what would be my first step as soon as i open the user manual documents."

    Shouldn't that be obvious?

    1) Spend some time paging through the rather large document to see what different chapters there are.

    2) Spend some more time with the chapters that seems to be relevant to your interests.

    3) Blinking a LED implies the use of an output from the processor. So focus on the chapter(s) covering GPIO (General Purpose Input/Output) configuration, i.e. how to use the processor pins "manually" for input/output as opposed to the special functions available where processor pins are associated with serial ports, interrupts etc.

    4) Return back to the example codes you have found, and look at the source code lines you see. If you don't understand what a specific line does, you can jump to the processor user manual and read the description for that specific register. Repeat and rinse until you understand what the example program does, and why.

    5) Modify the example program to add your own improvements based on your knowledge of the processor, and the information available in the processor user manual.

    6) Test your changes and see if you get the result you expected.

    7) Compare code with processor user manual again to figure out why your program did not behave as intended.

    8) Correct the code and repeat from point 6 until it works. Then repeat from point 5 with further code improvements.

  • OK P.Wmark..
    I will follow your suggestions rigoursly and will soon post.
    Thanks for your suggestions and motivative *** encouraging post.
    See you soon.

    Thanks & Regards,
    M.blue

  • See you soon.

    Take your time, bro, don't hurry.