• Latest Posts

    Subscribe my Youtube channel for mere videos

    Friday 10 February 2017

    LED blink with PIC18f2520 microcontroller


    LED blink with Pic microcontroller




    This chapter will explain you that how to start with microcontroller programming and topic will “make a LED blinking program for PIC18f2520 microcontroller with MPLAB IDE (C18 compiler)”.
    The aim of the program is to educate engineers that can conceive basic embedded system specifications, design such systems at the electronic system level (ESL ) and implement and verify such systems using state-of-the-art integrated circuit and electronic design automation tools. The program provides a deep coverage for the beginners to orientation his technical skills.

    You would need to know c language and microcontroller structure before to start. If you know basic C-language then you can go further topic otherwise nothing will be benefit to spend your time.


    Circuit diagram





    We are going to use PORTC pin0 for led connection as per given circuit.
    SO we would need to configure PORTC pin0 as output pin and configure setting of oscillator selection in IDE, because we are using external crystal for clock frequency.






    Codes

    #include <p18f2520.h>
    #define LED PORTCbits.RC0
    unsigned int count;
    void main ()
    {
              TRISC = 0;  // PORTC as output.
              LED = 0;     // Turn off led in starting.

              while (1)    // Infinite loop
              {
                       // Delay until count not reach 0xFFFF value.
                       for(count = 0; count < 0xFFFF; count = count + 1);  
                      
                       LED = 1;     // Turn on LED

                       // Delay until count not reach 0xFFFF value.
                       for(count = 0; count < 0xFFFF; count = count + 1); 
      
                       LED = 0;     // Turn off LED
              }
    }

    All of has been done and now you can upload hex file to your microcontroller and furthermore run in PROTEUS also. I have already tested this program. If any problem you are facing. You can ask me in comments. 









    Download MPLAB project :-   https://drive.google.com/file/d/0B886Kbl42IVuVUdkVWY2WVZFWnc/view?usp=sharing






    No comments:

    Post a Comment

    Fashion

    Beauty

    Travel