Karan123
May 31 2009, 3:07 AM
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




Apex::Code
May 31 2009, 7:30 AM
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.....
Karan123
May 31 2009, 7:55 AM
Thanks for Reply...

I am send to you Circuit and Source



Karan


mplab_first.zip
Apex::Code
May 31 2009, 8:10 AM
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...

Karan123
May 31 2009, 8:39 AM
How to Config Bits?


I am using PIC ICSP programmer.

How to change Analog pin to Digital pin?

Waiting your Reply..


Thanks


Karan

Apex::Code
May 31 2009, 10:35 AM
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;

 



Karan123
May 31 2009, 11:25 AM
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
Apex::Code
May 31 2009, 11:32 AM
gr8 all d best
Tech350
Jun 22 2009, 5:37 AM
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.
Ajay Bhargav
Jun 22 2009, 3:16 PM
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
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Rickey's World © 2003 - 2007