Previous in Forum: Web Pages   Next in Forum: Changing Circles to Points in AutoCAD LT 2010
Close
Close
Close
9 comments
Rate Comments: Nested
Participant

Join Date: Oct 2011
Posts: 4

Pic 16f873 Not Running Code While Simulator Does

10/22/2011 9:33 AM

hello everybody!

am an instrument student, am doin my final year project, it's a pic based coded security safe,am usin the 16f873,a 3x4 keypad is used to enter a 3 digit code that is displyed on 3 seven segments,when a correct code is enterred,a buzzer sounds and the safe is unlocked... i have written a code and simulate it on the mplab, it seemed to work, but when i download it in the chip and use it in the board, it is not running...i thought that it was maybe a problem with the code, i tried this time a simple code of turning on one of the leds in my project board, still it is not running...i ve tried the best i van to troubleshoot but still i cant get it right...i need help, any suggestion will be welcome, thanks in advance

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru

Join Date: Oct 2008
Posts: 42355
Good Answers: 1693
#1

Re: pic 16f873 not running code while simulator does

10/22/2011 10:15 AM

Ask your instructor for help.

Register to Reply
Guru
Engineering Fields - Electrical Engineering - Been there, done that. Engineering Fields - Control Engineering - New Member

Join Date: Dec 2008
Location: Long Island NY
Posts: 15600
Good Answers: 981
#2

Re: Pic 16f873 Not Running Code While Simulator Does

10/22/2011 1:52 PM

Break your code up into smaller routines and tasks. Verify that the smaller routines each work with being installed into the chip. Then start combining the individual routines one at a time into the chip.

A common problem that people have with simulators versus real life coding is that some simulators always start with memory registers being cleared. This will only be true with a real controller if you have an initialization circuit and code to execute clearing pertinent registers.

__________________
"Don't disturb my circles." translation of Archimedes last words
Register to Reply
Participant

Join Date: Oct 2011
Posts: 4
#3
In reply to #2

Re: Pic 16f873 Not Running Code While Simulator Does

10/22/2011 2:17 PM

Thank you Redfred for your interest As I said, I was suspecting my code to be wrong, but when am trying the different subroutines like interfacing the keypad with the 7 segments and even drive the buzzer, nothing happens...I even went down to the simplest code, setting all the leds high, but still it doesn't... There is the sample program that I tried to test: List p=16f873 Status equ 03 Rp0 equ 5 Adcon1 equ 9fh Trisb equ 86h Portb equ 06 Trisa equ 85h Porta equ 05 Bsf status,rp0 Clrf trisb Movlw 0x06 Movwf adcon1 Clrf trisa Bcf status,rp0 movlw 0ffh Movwf portb Movwf porta End ; this is suppose to activate all the displays and display 888, the 7 lines to the 7 segments are on portb, 3 lines for the transistors to switch them on porta, and the buzzer also on porta...but when try it on the chip and the board nothing...am using a 4Mhz xtal, with 22pf

Ps: right now am using my phone, can't edit properly

Register to Reply
Guru
Engineering Fields - Electrical Engineering - Been there, done that. Engineering Fields - Control Engineering - New Member

Join Date: Dec 2008
Location: Long Island NY
Posts: 15600
Good Answers: 981
#5
In reply to #3

Re: Pic 16f873 Not Running Code While Simulator Does

10/22/2011 2:24 PM

As Lyn said earlier; you now need hands, eyes and experience that are familiar with the test hardware configuration you have. You're now experiencing the most frustrating aspect of embedded digital control, it works or it doesn't work.

__________________
"Don't disturb my circles." translation of Archimedes last words
Register to Reply
Guru

Join Date: Jul 2008
Posts: 1688
Good Answers: 145
#4

Re: Pic 16f873 Not Running Code While Simulator Does

10/22/2011 2:21 PM

Is this a purchased eval board? If so, can you reload the demo programs that came with it?

__________________
Few things limit our potential as much as knowing answers and setting aside questions.
Register to Reply
Participant

Join Date: Oct 2011
Posts: 4
#6
In reply to #4

Re: Pic 16f873 Not Running Code While Simulator Does

10/22/2011 3:44 PM

Nope its not, I made the board myself...

Register to Reply
Guru
New Zealand - Member - Kiwi Popular Science - Weaponology - New Member Engineering Fields - Power Engineering - New Member Engineering Fields - Electrical Engineering - New Member

Join Date: Sep 2006
Location: Auckland, New Zealand
Posts: 8777
Good Answers: 376
#7
In reply to #6

Re: Pic 16f873 Not Running Code While Simulator Does

10/24/2011 2:19 PM

Check all your electrical connections and connectors, soldered joints, connectors, component orientation and connectors, connectors, etc. chances are it is a simple hardware problem.

How did you make your circuit? Breadboards with press fit components are notorious for problems (one student I knew spent a full day trying to fault find a hardware problem only to discover the breadboard itself was faulty).

Even if every thing is wired correctly the circuit may still not work if layout and design mistakes are made. One group of students I knew thought it was a good idea to fit a 40-odd pin microcontroller chip into a socket and then connect it to their main board using long soldered wires, they never got it to work.

Note that I mentioned connectors numerous times, these are the most likely component to cause problems, and unlike incorrect component orientation can be intermittent and difficult to trace.

Let us know what you find.

__________________
jack of all trades
Register to Reply
Participant

Join Date: Oct 2011
Posts: 4
#8
In reply to #7

Re: Pic 16f873 Not Running Code While Simulator Does

10/24/2011 2:56 PM

thank you Jack, i checked the hardware board, and it seemed to be fine, i tried the same sample flashing Led program using picbasic pro and this time it worked, i also tried a couple of other programs...now, i dont understand why it didn't work with the assembly? is there a way to convert between the 2? because am a beginner in PBP and am submitting the project by the end of this semester...

Register to Reply
Guru
New Zealand - Member - Kiwi Popular Science - Weaponology - New Member Engineering Fields - Power Engineering - New Member Engineering Fields - Electrical Engineering - New Member

Join Date: Sep 2006
Location: Auckland, New Zealand
Posts: 8777
Good Answers: 376
#9
In reply to #8

Re: Pic 16f873 Not Running Code While Simulator Does

10/24/2011 7:18 PM

Not sure, could be something as simple as a version or setting error in the compile or assembly program. This isn't really my field but someone else may have some ideas.

__________________
jack of all trades
Register to Reply Off Topic (Score 5)
Register to Reply 9 comments
Copy to Clipboard

Users who posted comments:

BruceFlorida (1); digryo (3); jack of all trades (2); lyn (1); redfred (2)

Previous in Forum: Web Pages   Next in Forum: Changing Circles to Points in AutoCAD LT 2010

Advertisement