Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] LED Blinking Working in Proteus But not in Real Harware MCU

Status
Not open for further replies.

kanni1303

Full Member level 3
Joined
Jun 29, 2012
Messages
164
Helped
12
Reputation
24
Reaction score
11
Trophy points
1,298
Location
Chennai, Tamil Nadu, India
Activity points
2,706
I tried with my program and also with other from net... but the problem i receive on all time... My PIC is new one i got it and aged about 1 week only... i don't know what is the problem... i tried as it is in the attached one... and also the one from this site... LED Blinking...
I don't know what may be problem...
may be crystal side, Mcu side or programming side...
really i am blanked out... this only perfectly executed in previous Mcu PIC16F877A but i wrongly burned that earlier and got new one recently and for the first i tried LED blinking to start but it is not working...
while programming it says no error... i use PIC KIT 2....
 

Attachments

  • PIC16F877 LED Blinking Code.rar
    64.2 KB · Views: 104

If the led glows with this program in earlier MCu. Then sure it should work. In your case, you have burned your micro-controller. So there might be a problem with the crystal. Also double check the led is good.
If you have scope, check the oscillator. Else, replace it with the new 20Mhz crystal and load the program in your mcu. It should work because even i have come across your problem.

Best wishes :)
 

I dont have oscilloscope... but i used four crystals(4MHz, 12MHz, 20MHz , 20MHz)... and Led Mcu all are new one... Led glows perfectly...
here is my prev code
Code:
#include<htc.h>
#include "delay.c"
#include "delay.h"

#define op1 RB6 
#define op2 RB7

void main(void)
{

TRISB = 0x00; //Sets port B as an OUTPUT port
PORTB = 0x00;
for(;;)
{
op1=0x00;
op2=0xff;
DelayMs(200);
op1=0xff;
op2=0x00;
DelayMs(200);
}
}
i selected config bits in configure menu and exported the .HEX code and burned to MCU...
how to check whether by cystal and MCu is working or not...
and thnks for your help
 

What you have done looks good, The two possibilities as to why it does not work are the crystal not oscillating, try a simple RC oscillator instead, or you have not programed the configuration word correctly. Don't forget to turn off the watchdog timer and set the oscillator mode correctly.
 

Try the below program. Also, please check that you have selected correct configuration bits.
HTML:
#include<htc.h>
__CONFIG( FOSC_HS & WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON 
      & LVP_OFF & CPD_OFF & WRT_ON & DEBUG_OFF);
#define _XTAL_FREQ   20000000
#define LED  RB0
void main(void)
{
   TRISB0 = 0;               // Make RB0 pin output
   LED    = 0;               // Make RB0 low
   while(1)
   {
      __delay_ms(500);       // Half sec delay
      LED = 0;               // LED off
      __delay_ms(500);       // Half sec delay
      LED = 1;               // LED on
   }
}
Please change new 20Mhz cystal and try it once.

but i used four crystals(4MHz, 12MHz, 20MHz , 20MHz)
When you use these crystals, you must also change it in coding.
 

I set CONFIG Bit to 3F3A
means
HS oscillator
WDT disabled
PWRT disabled
BOR diabled
RB3 is dig I/O
Data EEPROM Code protection off
write protection off
code protection off

What you have done looks good, The two possibilities as to why it does not work are the crystal not oscillating, try a simple RC oscillator instead, or you have not programed the configuration word correctly. Don't forget to turn off the watchdog timer and set the oscillator mode correctly.

- - - Updated - - -

i see an error
"Error [800] LED Bl.as; 45. undefined symbol "WRT_ON""

Try the below program. Also, please check that you have selected correct configuration bits.
HTML:
#include<htc.h>
__CONFIG( FOSC_HS & WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON 
      & LVP_OFF & CPD_OFF & WRT_ON & DEBUG_OFF);
#define _XTAL_FREQ   20000000
#define LED  RB0
void main(void)
{
   TRISB0 = 0;               // Make RB0 pin output
   LED    = 0;               // Make RB0 low
   while(1)
   {
      __delay_ms(500);       // Half sec delay
      LED = 0;               // LED off
      __delay_ms(500);       // Half sec delay
      LED = 1;               // LED on
   }
}
Please change new 20Mhz cystal and try it once.


When you use these crystals, you must also change it in coding.
 

I think LED Bl.as is the assmebly source file name. It is telling that WRT_ON is an undefined symbol.

__CONFIG( FOSC_HS & WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON
& LVP_OFF & CPD_OFF & WRT_ON & DEBUG_OFF);
 

i solved it.. i used 0.1uF capacitors across the crystal that is the problem... i removed those and now working fine... thnx for ur reply...
once again thanks....
 

Read "Oscillator Configurations" in your datasheet. Use the capacitor value which mentioned by the manufacturer.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top