raafia
Junior Member level 1
- Joined
- Dec 24, 2009
- Messages
- 16
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,413
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #include<htc.h> __CONFIG( FOSC_HS & WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON & LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_OFF); // Define LED pin #define LED RB0 #define _XTAL_FREQ 20000000 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 post the schematic of the circuit, including details concerning the LED and clock source circuitry.
What versions of the MPLAB and Hi-Tech Compiler are you using?
How are you programming the PIC, utilizing a PICkit, ICD, etc?
After programming does the MPLAB IDE verify and indicate programming was successful?
After programming are you running the code in debug mode or releasing/resetting the device?
BigDog
are you using battery power circuit ???
place a resistor between the Vdd and MCLR (to limit the current).
hi
check the clock circuit! are you using a crystal with 2 caps (between 15 and 22 pF)?
__CONFIG( FOSC_HS & WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON & LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_OFF);
__CONFIG( FOSC_XT & WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON & LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_OFF);
#define _XTAL_FREQ 20000000
Have you put a resistor of around 330 Ohms in series with the LED. If not your LED is already dead.
- - - Updated - - -
@kgavionics
She has mentioned #define _XTAL_FREQ 20000000 . So clock is HS.
Are you testing the Circuit on breadboard?
hi raafia
i notice someting about your code, you declaredtry to replace it by that if you are using a crystal below 4 MHZCode:__CONFIG( FOSC_HS & WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON & LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_OFF);
Code:__CONFIG( FOSC_XT & WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON & LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_OFF);
Both the HS and XT oscillator settings are acceptable for a 4MHz or higher frequency crystal, I typically use the latter HS setting as most of my designs use 4MHz or higher frequencies, so that should not be the issue.
However, you have indicated the crystal frequency is 20MHz in the following line:
Code:#define _XTAL_FREQ 20000000
Is this not correct? I cannot determine the crystal frequency from the schematic as it is too small.
You definitely need to use the pullup resistor on MCLR and 10kΩ is am appropriate value.
Another item lacking from your design is a bypass/decoupling capacitor, typically 100nF, attached as close as possible between the Vdd (5v) and Vss (GND) pins of the PIC.
You might also turn off Brown Out Detection (BOREN) as ripples on the power supply can cause the PIC to constantly reset itself or essential remain in a reset state.
Which brings me to your power supply. What is it and how well is it regulated? If it is just a common wall wart you may need to build a properly regulated PS using a 7805 and some filter caps.
What is the power quality in your locale, brown outs, outages, voltage spikes, etc, come in your locale?
Also, when you compile the code, do you have debug or release selected in the project configuration?
BigDog
I have selected debug in project configuration .Should it be the other way round ?
Current limiting resistor. PIC pins can source or sink 25 mA max. LED can handle max 20 mA. Your LED is dead.
Thankyou so much ..i will check that .The other way around.
If you are not using an in-circuit debugger, which you've already deactivated in the configuration register settings, select "release" and recompile.
BigDog
After ad595 i am getting .25volts for room temperature and .39 volts for human body
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?