Philippine Electronics Forum
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Help
Search
Login
Register
Philippine Electronics Forum
»
Digital Electronics
»
Microcontroller/Microprocessor Unit Projects and Programming
»
PIC Microcontrollers
(Moderators:
marcelino
,
paranz
) »
PIC Beginner Question, Problem with very simple LED circuit (?!)
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: PIC Beginner Question, Problem with very simple LED circuit (?!) (Read 565 times)
patriots21
CR2032 Battery
Posts: 22
Pogi/Ganda Points: 0
PIC Beginner Question, Problem with very simple LED circuit (?!)
«
on:
August 13, 2011, 12:34:17 PM »
Good day mga sir, nagsimula palang akong magka-interest sa microcontroller programming kahapon and one of the people I know told me that learning PIC would be a good start.
Anyway I'm trying this very simple LED circuit which I can't get to work. I'm using the PICf877A as my PIC, mplab and then epickit2 from e-gizmo as my programmer (kakabili ko lang din kahapon, gusto ko kasi talaga matuto). I found this little tutorial on PIC programming using assembly language at sinubukan ko itong unang circuit.
Of course, dahil ibang PIC gamit ko, sinubukan kong iimplement in a different way using my PIC16F877A
Ang problem ko is hindi man lamang umilaw yung LED ko. I checked din yung voltage ng output pins ko (patin na din lahat ng pins actually) with respect sa ground, at lahat sila 0 volts, (except, of course dun sa nakakabit externally sa 5 volts rail at yung nakaconnect dun sa crystal)
Also, because this is the first time I ever even touched a PIC, or a microcontroller for that matter, hindi rin ako sigurado kung tama ang way ng pagprogram ko. Nagrerefer lang ako sirs and ma'ms sa datasheet ng pickit2 (which is the same for the epickit2 from e-gizmo).
Ganito po ginawa ko:
Pin ng programmer Corresponding pin ng PIC
VPP /MCLR (pin1)
VDD VDD (pin 11)
GND VSS (pin12)
DAT RB7/PGD (pin 40)
CLK RB6/PGC (pin 39)
AUX --- (no connection)
At ito naman ang aking code using microchip MPASM tolsuite ng MPLAB (binuild ko sirs and ma'ms sa hex and then inimport ko at niwrite using pickit2 software na kasama nung programmer ko)
;----------------------------------------------------------------------------
#include "p16f877A.inc" ; Microchip INC database
LIST P=PIC16F877A
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC
org 0x00
bsf STATUS,5
movlw 00h
movwf TRISB
bcf STATUS, 5
Start movlw 02h
movwf PORTB
goto Start
end
;----------------------------------------------------------------------------
Bale mag-oon lang po yung LED pag nagkabit ako ng source then that's it, haha. napakasimple lang po pasensya na, at inaasume ko po na hindi mahalaga yung value ng crystal para makita ko yung pag-ilaw ng LED kasi pagpapa-ON lang naman ginawa ko. Pero ayaw niya po mag-on at wala ding voltage dun sa RB1 which is ginagawang HIGH dapat ng PIC. So ang hinala ko baka hindi naload sa PIC yung program.
Also, nung ni-write ko na yung hex file sa PIC, pagkakita ko ng "Succesfully Programmed" tapos pagka verify ko din, tinangal ko na yung connections ko. May kailangan pa po bang gawin? (hindi po in-circuit yung pag-program ko). Napansin ko din po na dalawa ang VCC and VDD pins ng PIC ko, sinubukan ko gamitin yung isang VCC and VDD lang at sinubukan ko na din iconnect sila pareho sa source at sa ground, all this to no avail.
Help will be greatly appreciated. Tsaka, I sincerely apologize for those people who will find my problem way too trivial, beginner lang po talaga ako and I tried na din po everything I can think of. Nagbabasa naman po ako ng mga tutorials since kahapon and I feel na sapat na yung nalaman ko para atleast magawa ko tong napaksimpleng bagay na to. Ipagpapatuloy ko ang pa-aaral ko as soon as I get this one under my belt, para bang just to get myself off the right foot. Pasensya na din po kung may mali dito sa post ko (like being in the wrong subforum) bago din lang po ako dito. Hoping for friendly replies po, Animo sa inyong lahat!
Sinubukan ko din pong magsama ng schematic pero sabi sakin "Sorry, you are not yet allowed to post links."
Logged
Philippine Electronics Forum
PIC Beginner Question, Problem with very simple LED circuit (?!)
«
on:
August 13, 2011, 12:34:17 PM »
tiktak
Gas Turbine
Posts: 2859
Pogi/Ganda Points: 203
Gender:
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #1 on:
August 13, 2011, 12:49:28 PM »
Did you tie the MCLR to VDD? it is a must to pull up the MCLR at normal operation, if your crystal is 4Mhz and below the config should be XT else greater than that HS
Logged
8051 stuff
Philippine Electronics Forum
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #1 on:
August 13, 2011, 12:49:28 PM »
patriots21
CR2032 Battery
Posts: 22
Pogi/Ganda Points: 0
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #2 on:
August 13, 2011, 01:22:52 PM »
yes sir, MCLR is tied to VDD (5 volts) and my crystal is 20 Mhz so I used HS. Also I forgot to mention that my source comes from a simple voltage divider arrangement which reduces the voltage from my 9-volts battery to something around 5 volts (4.8V)
Logged
Philippine Electronics Forum
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #2 on:
August 13, 2011, 01:22:52 PM »
rdpzycho
Technical People
Solar Power Satellite
Posts: 10728
Pogi/Ganda Points: 632
Gender:
Respect Begets Respect
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #3 on:
August 13, 2011, 01:24:28 PM »
^ naku baka bumabagasak 'yung voltage mo. measure VDD kapag running na 'yung MCU. mas maganda kung regulator gagamitin mo, voltage dividers are only used for fixed current loads at reference voltages.
Logged
"Divide each difficulty into as many parts as is feasible and necessary to resolve it."
- Rene Descartes
"For every difficult problem there is always a simple answer and most of them are wrong."
- Clayton Paul
Philippine Electronics Forum
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #3 on:
August 13, 2011, 01:24:28 PM »
PlCUSER
Diesel Generator
Posts: 1909
Pogi/Ganda Points: 153
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #4 on:
August 13, 2011, 01:30:17 PM »
try to power your circuit with pickit2 na lang muna. kung wala kang 5V supply.
Logged
Philippine Electronics Forum
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #4 on:
August 13, 2011, 01:30:17 PM »
patriots21
CR2032 Battery
Posts: 22
Pogi/Ganda Points: 0
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #5 on:
August 13, 2011, 01:51:58 PM »
to power my circuit using the pickit2, I simply connect the /msclr and VDD to their repsepctive pins sa pickit2? and then leave the other pins of the pickit2 unconnected?
and pwede ba ako gumamit ng voltage rgulator na ic tulad nitong 7805
Logged
tiktak
Gas Turbine
Posts: 2859
Pogi/Ganda Points: 203
Gender:
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #6 on:
August 13, 2011, 02:20:17 PM »
^mas maganda kung 7805 nalang ginamit mo, to power from pickit2, sa mplab click mo vdd on, or power target, tapos after ma program click mo yung release from reset sa programmer pull down menu
Logged
8051 stuff
motion55
Technical People
Diesel Generator
Posts: 1881
Pogi/Ganda Points: 244
Gender:
Been at this longer than you've been alive.
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #7 on:
August 13, 2011, 04:10:36 PM »
First things first. Check the power supply first.
Make sure your PIC is supplied with a stable and clean 5V supply. Dropping them using a resistor voltage divider will not do. Put a 0.1uF ceramic capacitor at the supply and ground pins (VDD pins 11 & 32 and GND pin 12 & 31). Connect MCLR to VDD.
Does the crystal have some loading capacitors on each pin (about 22pf) to GND?
Logged
"Set your mind free!"
ultrasonic™
Solar Power Satellite
Posts: 6983
Pogi/Ganda Points: 915
Gender:
never be harsh coz everythng is fine
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #8 on:
August 13, 2011, 06:33:35 PM »
subscribe
Logged
im always walking on the rain so that no one could see me crying
TV SERVICE MODE -
http://www.elab.ph/forum/index.php?topic=2267.0;topicseen
patriots21
CR2032 Battery
Posts: 22
Pogi/Ganda Points: 0
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #9 on:
August 14, 2011, 03:58:46 PM »
thanks for the replies guys, I really appreciate it.
So i tried powering my PIC with the 7805 and also with VDD from the e-pickkit2, still no luck.As of the moment I have no capacitor connected to the GND and supply pins as well as no loading capacitor at the pins of the 20mhz crystal. I'll try adding them once I get the chance to stop by an electronic store so that I can get myself some additional components.
Also there's this funny thing that happens when I try to program my pic using the pickit2 software. Sometimes, after I have written (and Verified) the hex file into the PIC, whenever I check if the PIC is blank using the Blank Check function of the software, I would get the message that the PIC is blank. I mean, how can it be blank if I just finished loading the hex file into it (signified by the "Successfully Programmed" message by the software). There's also this thing that when I use the Erase function, the Blank function would tell me that the PIC is not empty. May be I'm doing it wrong, or may be I already broke my PIC with my earlier attempts to make it work.
Logged
motion55
Technical People
Diesel Generator
Posts: 1881
Pogi/Ganda Points: 244
Gender:
Been at this longer than you've been alive.
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #10 on:
August 14, 2011, 05:28:39 PM »
How are you programming the device? If it is on a makeshift breadboard, make sure the PIC's supply and ground pins have a bypass capacitor close to the pins as well.
Logged
"Set your mind free!"
patriots21
CR2032 Battery
Posts: 22
Pogi/Ganda Points: 0
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #11 on:
August 14, 2011, 05:38:53 PM »
With my PIC16f877a on a breadboard, I use jumper wires to connect directly to the epickit2.
Pin of the programmer Corresponding pin of the PIC
VPP /MCLR (pin1)
VDD VDD (pin 11)
GND VSS (pin12)
DAT RB7/PGD (pin 40)
CLK RB6/PGC (pin 39)
AUX --- (no connection)
Actually, I haven't tried connecting the two VDDs and VSSs together while programming. I read somewhere that they are internally connected. Anyway I'll have a go at it again with these connected. And yes, I have no by-pass capacitors at the VDD and GND pins while programming. I'll include these as well.
Logged
motion55
Technical People
Diesel Generator
Posts: 1881
Pogi/Ganda Points: 244
Gender:
Been at this longer than you've been alive.
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #12 on:
August 14, 2011, 06:40:39 PM »
Think about it. If the device only needed one set of supply and ground pins, why would Microchip sacrifice a pair of pins for extra supply and ground. The pins could have been used as I/O.
Relying on the internal connection might work but you are here and the programmer and/or the device do not seem to work. Best not to be sloppy and tie up loose ends.
Logged
"Set your mind free!"
patriots21
CR2032 Battery
Posts: 22
Pogi/Ganda Points: 0
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #13 on:
August 14, 2011, 10:47:25 PM »
added 0.1uF bypass capacitors at both set of Vcc and Vdd pins (as close to the pins as possible, as you guys have mentioned). Connected both Vcc pins to the supply and both Vdd pins to ground while programming and while testing the uC. Added capacitors at both pins of the 20 mHz crystal while testing. Checked continuity of all my jumper wires. Checked voltage at Vcc and Vpp pins of the pickit2 using voltmeter. Still nothing, I seem to have hit a brick wall here.
Logged
motion55
Technical People
Diesel Generator
Posts: 1881
Pogi/Ganda Points: 244
Gender:
Been at this longer than you've been alive.
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #14 on:
August 15, 2011, 03:55:49 AM »
In most setups, the hardest part is booting up, where you do not know if the tools themselves work in the first place. That is why they sell those starter kits. A setup that is known to work.
Maybe you should bring your programmer to e-gizmo for them to check if it is working. Do you have only one PIC?
Logged
"Set your mind free!"
Philippine Electronics Forum
Re: PIC Beginner Question, Problem with very simple LED circuit (?!)
«
Reply #14 on:
August 15, 2011, 03:55:49 AM »
Print
Pages: [
1
]
Go Up
« previous
next »
Philippine Electronics Forum
»
Digital Electronics
»
Microcontroller/Microprocessor Unit Projects and Programming
»
PIC Microcontrollers
(Moderators:
marcelino
,
paranz
) »
PIC Beginner Question, Problem with very simple LED circuit (?!)
Privacy Policy
Contact Us: elabph@yahoo.com