free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Rickey's World :: Discussion Forums :: Discuss and Learn :: PIC Microcontroller Discussion
 
<< Previous thread | Next thread >>
PIC18F4520 : LED Blinking
Moderators: Ajay Bhargav, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph, ExperimenterUK, DavesGarage
Author Post
Karan123
Sun May 31 2009, 03:07AM
 User Offline
Registered Member #14782
Joined: Mon Feb 02 2009, 06:45PM

Posts: 66
Thanked 1 time in 1 posts
Hello,

I am new For PIC MICROCONTROLLER (PIC18F4520) Series.

I have successfully Write Program for Blink LED and Checked on
MPLAB Simulator.

Now I have to Check that with Actual Hardware.

I have Connected

C1 and C2 22 pF and X'Tal of 4.00 MHz

PIN 13 and 14 for Osc.

PIN 32 and 11 to VCC.

PIN 31 and 12 to GND.

RESET Switch ON PIN 1 with GND

LED CONNECTED ON PIN2 RA0.


I have successfully Program HEX file to PIC uC.

But Unable to Blink LED on Actual Hardware

Please Guide me How to Trouble shoot Above Problem?


Karan








Karan

Back to top

Apex::Code
Sun May 31 2009, 07:30AM
 User Offline
Registered Member #16399
Joined: Thu Mar 12 2009, 02:19AM

Posts: 36
Thanked 9 times in 9 posts
if u r sure of h/w then there must be some problem in s/w
please post s/w

first program to just glow a LED on a port

then program to keep it off

if both work successfully there chud be no prblm with h/w

then to blink..... see that you have enough delay atleast of 1s so that u can see the blinking.....

Back to top


This post has been thanked 1 time
 Karan123 
Karan123
Sun May 31 2009, 07:55AM
 User Offline
Registered Member #14782
Joined: Mon Feb 02 2009, 06:45PM

Posts: 66
Thanked 1 time in 1 posts
Thanks for Reply...

I am send to you Circuit and Source



Karan


mplab_first.zip

Karan

Back to top

Apex::Code
Sun May 31 2009, 08:10AM
 User Offline
Registered Member #16399
Joined: Thu Mar 12 2009, 02:19AM

Posts: 36
Thanked 9 times in 9 posts
the code seems right!!! but some config is missing.......which programmer are u using??? i don't see the config bits set and neither ........... and u need to set port a pins as digital pins bcoz they can act as analog too...



Back to top


This post has been thanked 1 time
 Karan123 
Karan123
Sun May 31 2009, 08:39AM
 User Offline
Registered Member #14782
Joined: Mon Feb 02 2009, 06:45PM

Posts: 66
Thanked 1 time in 1 posts
How to Config Bits?


I am using PIC ICSP programmer.

How to change Analog pin to Digital pin?

Waiting your Reply..


Thanks


Karan



Karan

Back to top

Apex::Code
Sun May 31 2009, 10:35AM
 User Offline
Registered Member #16399
Joined: Thu Mar 12 2009, 02:19AM

Posts: 36
Thanked 9 times in 9 posts
sorry for late reply...........

well u have to configure it through your code which is better than setting config bits thru PICPgm Develop. Programmer every time u burn pgm into PIC.

like in C:

CODE:

#pragma config OSC = XT    /* Sets the oscillator mode to XT for cristal up to 4MHz or HS=>4MHz */
#pragma config WDT = OFF   /* Turns the watchdog timer off */
#pragma config LVP = OFF   /* Turns low voltage programming off */
#pragma config DEBUG = OFF /* Compiles without extra debug code */
.
.
.
.
.
.
.
.
.
 




many config bits r there which needs to be set rather than leaving it for default....
refer C18 manual in MPLAB-> HELP-> Help Topics
it has all config bit settings explained ..... or u can even refer datasheet under chapter --- 'Special Features' which will be in end chapters of datasheet

next in main() initialize and assign default values, like this:

CODE:


       ADCON1   = 0b00001111;   //all A/D port set as digital


       TRISA   = 0b0000000;   // output
        TRISB   = 0b00000000;   //all output
        TRISC   = 0b10000000;   //all output
        TRISD   = 0b00000000;   //all output
        TRISE   = 0b00000000;   //all output    

        PORTA      = 0b00000000;   //Initialize port default output state
        PORTB      = 0b00000000;
        PORTC      = 0b00000000;        
        PORTD      = 0b00000000;
        PORTE      = 0b00000000;        
        INTCON          = 0b00000000;   //disable interrupts
        INTCON3         = 0b00000000;   // disable ext intrpt.
        PIE1            = 0b00000000;
        PIE2            = 0b00000000;

 





Back to top


This post has been thanked 1 time
 Karan123 
Karan123
Sun May 31 2009, 11:25AM
 User Offline
Registered Member #14782
Joined: Mon Feb 02 2009, 06:45PM

Posts: 66
Thanked 1 time in 1 posts
Thanks For Support!!!!!!!!


I have successfully Checked on Own Hardware...

Please check attachment.

I am working for 8051 from last 3 years?
Now move to PIC.

Thanks again,..

Karan

pic18f4520_with_blink_led.rar

Karan

Back to top

Apex::Code
Sun May 31 2009, 11:32AM
 User Offline
Registered Member #16399
Joined: Thu Mar 12 2009, 02:19AM

Posts: 36
Thanked 9 times in 9 posts
gr8 all d best

Back to top


This post has been thanked 1 time
 Karan123 
Tech350
Mon Jun 22 2009, 05:37AM
 User Offline
Registered Member #19049
Joined: Thu Jun 04 2009, 03:07AM

Posts: 29
Thanked 0 times in 0 posts
Hi Karan,

I'm working on a PIC18F8520 for awhile now and I it is similar to your PIC18F4520. I'm using a MikroC IDE and I it is amazing and built for PIC MCUs. Download a trial version of MikroeC from the net and check it out. There are example programs along with the circuit diagram. LED blinking is a very basic code and you shouldn't have so much trouble with it.


In my case a program is something which always converts data into error messages!!
Back to top

Ajay Bhargav
Mon Jun 22 2009, 03:16PM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 7484
Thanked 1323 times in 1247 posts
Karan, remember when you are using MPlab, i recommend you to use the GUI interface for configuration bits setting of PIC (Configure->configuration bits), just to make sure you did not miss any of the important stuff. Also make sure you have selected the right device before programming and making changes in configuration bits.

and PortA of PIC is analog port by default, it must be configured as Digital before using it as digital I/O port.

best of luck

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top

 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems