Searching \ for '[PIC]: Port A vs. Port D on 16F877' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=port
Search entire site for: 'Port A vs. Port D on 16F877'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Port A vs. Port D on 16F877'
2001\12\26@123754 by Dave Dribin

flavicon
face
part 1 1350 bytes content-type:text/plain; charset=us-asciiHello all,

I wrote my very first PIC program yesterday, and I'm having some
troubles.  I took the LEDON program from Myke's book (attached).  The
only modification I made to the code was to specify _HS_OSC in the
config bits because I'm running on a 16F877 with a 20Mhz crystal.  I
made a couple minor hardware modifications as compared to the notes:
used a 10K pull-up on _MCLR and used a 330 Ohm resistor as the LED
pull-up.

So what happens?  Nothing.  The LED never changes.  It works in my
simulator (gpsim), though.  Ok, so how do I know it's not hardware?
Well, it works if I change Line 47 to:

  47     movf   PORTD, w               ;  Simply Transfer PORTD.0 to PORTB.0

So, using RD0 as input instead of RA0 works.  Do I have to do some
setup for Port A?  It should be an input out of reset, so I'm not sure
what I am missing.  BTW, the config word read from the real PIC using
a PICSTART Plus is 0x3f72, which looks correct:

Config: 11111101110010

  CP: Code Protection Off
DEBUG: In-Circuit Debugger disabled, RB6 and RB7 are I/O
 WRT: Unprotected memory may be written to by EECON
 CPD: Code protection off
 LVP: Low voltage programming disabled, RB3 is I/O
BODEN: Brown-out Reset enabled
  CP: Code Protection Off
PWRTE: Power-up Timer enabled
WDTE: Watchdog Timer disabled
FOSC: HS oscillator

Thanks for any help.

-Dave


part 2 1373 bytes content-type:text/plain; charset=us-ascii
title  "ledon - Turn on a LED when a Button is Pressed"
;
;  This is the First Program to be Burned in and Run in a PIC.
;
;  The Program simply sets up Bit 0 of Port "A" to Output and then
;   Sets it Low when RA0 is pulled low.
;
;  Hardware Notes:
;   _MCLR is tied through a 4.7K Resistor to Vcc and PWRT is Enabled
;   A 220 Ohm Resistor and LED is attached to PORTB.0 and Vcc
;   A 10K pull up is connected to RA0 and it's state is passed to
;    RB0
;
;  Myke Predko
;  99.12.03
;
 LIST R=DEC
ifdef __16F84
 INCLUDE "p16f84.inc"
endif
ifdef __16F877
 INCLUDE "p16f877.inc"
endif

;  Registers

ifdef __16F84
__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON
else
__CONFIG _CP_OFF & _DEBUG_OFF & _HS_OSC & _PWRTE_ON  & _WDT_OFF & _LVP_OFF & _WRT_ENABLE_ON & _BODEN_ON & _CPD_OFF
endif

 PAGE
;  Mainline of ledon

org     0

 nop                           ;  "nop" is Required for Emulators

 bsf    PORTB, 0               ;  Make the LED on PORTB.0 "off"

 bsf    STATUS, RP0            ;  Goto Bank 1 to set Port Direction
 bcf    TRISB ^ 0x080, 0       ;  Set RB0 to Output
 bcf    STATUS, RP0            ;  Go back to Bank 0

Loop
 movf   PORTA, w               ;  Simply Transfer PORTA.0 to PORTB.0
 movwf  PORTB

 goto   Loop


end


part 3 136 bytes
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\12\26@124807 by Dale Botkin

flavicon
face
On Tue, 25 Dec 2001, Dave Dribin wrote:

{Quote hidden}

On the 16F877, PORTA is set as analog input by default.  You'll need to
turn off the ADC.

Dale
---
"Curiosity is the very basis of education and if you tell me that
curiosity killed the cat, I say only the cat died nobly."
         - Arnold Edinborough

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body


2001\12\26@124820 by Dave Dribin

flavicon
face
On Tue, Dec 25, 2001 at 12:31:45PM -0600, Dave Dribin wrote:

[ .. snip .. ]

> So, using RD0 as input instead of RA0 works.  Do I have to do some
> setup for Port A?  It should be an input out of reset, so I'm not sure
> what I am missing.

Ok.. so after RTFM, yes, I do have to setup Port A. :) I checked the
16F87X data sheet and it's setup as an *analog* input out of reset,
not digital.  Sorry for the noise, but I didn't expect a simple
example like this off the book's CD-ROM to have such a simple bug.

-Dave

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body


2001\12\26@162925 by Lawrence Lile

flavicon
face
Don't be ashamed, after using PICs for almost 10 years I still have circuits
that don't work, and I go back to the "one-LED'Blinky" to see what basic
&%&$###@#@|{}!!!  thing I've left off this time.  Often it is something like
not setting a TRIS register, not turning off analog inputs, or forgetting to
GOTO MAIN before all the subroutines and macros, every time something so
stupid I can stare at it and not see it.  It only takes one bad line of code
to make a mess of your program.

Keep this LED blinky circuit handy, it's a great troubleshooting tool.  the
LED is the ultimate poor-man's emulator - you know you are alive if the LED
blinks, and it can count for you, blink patterns for error messages, and
prove you got from Point A to Point B in the code.

These kind of questions are NOT noise, there are no stupid questions on the
PIClist (except "how do I unsubscribble?")
--Lawrence

{Original Message removed}

2001\12\26@171410 by David VanHorn

flavicon
face
>
>Keep this LED blinky circuit handy, it's a great troubleshooting tool.  the
>LED is the ultimate poor-man's emulator - you know you are alive if the LED
>blinks, and it can count for you, blink patterns for error messages, and
>prove you got from Point A to Point B in the code.
>
>These kind of questions are NOT noise, there are no stupid questions on the
>PIClist (except "how do I unsubscribble?")
>--Lawrence


Indeed.

I use a version of this in AVR projects, a subroutine called PING.
Ping puts a number of pulses on a single pin.
With a scope, I look at the pings, and I can watch what's going on.

ldi     TEMP,5
rcall   Ping

Pop a few of these in key areas, like ISRs, and you'll have a very good
idea what's happening (or not happening)

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam.....mitvma.mit.edu with SET PICList DIGEST in the body


2001\12\26@173938 by myke predko

flavicon
face
Hi Dave,

I'm sorry for the problems that simple application caused you.

Right now, we're preparing for a new printing - I'll make sure that problem
has been fixed before it goes to press.

I do appreciate your pointing it out to me so that I can get it fixed (and
make sure there aren't any other problems like it).

myke

{Original Message removed}

2001\12\26@193828 by Dave Dribin

flavicon
face
On Wed, Dec 26, 2001 at 05:39:35PM -0500, myke predko wrote:
> Hi Dave,
>
> I'm sorry for the problems that simple application caused you.
>
> Right now, we're preparing for a new printing - I'll make sure that problem
> has been fixed before it goes to press.

Wow!  It's always good to get direct feedback from the author.  Thanks
for taking note.  As a suggestion, you may want to put up errata like
this on your website.  I noticed you had a section for errata, but
there wasn't a whole lot there.

> I do appreciate your pointing it out to me so that I can get it fixed (and
> make sure there aren't any other problems like it).

Do you give out $2.56 for errors? :) I'm sure I will be working
through more examples in the upcoming weeks, so I'll keep my eye out.

Thanks for the open arms of others on this list, too!  It's been years
since I've done any hardware work, and sometimes its a bit
intimidating to get back into it.  It's amazing how much you forget if
you don't practice it.

-Dave

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body


2001\12\26@200719 by Kathy Quinlan

flavicon
face
----- Original Message -----
From: "David VanHorn" <dvanhornspamspam_OUTCEDAR.NET>

> I use a version of this in AVR projects, a subroutine called PING.
> Ping puts a number of pulses on a single pin.
> With a scope, I look at the pings, and I can watch what's going on.
>
> ldi     TEMP,5
> rcall   Ping
>
> Pop a few of these in key areas, like ISRs, and you'll have a very good
> idea what's happening (or not happening)


Mmmmmmmm Nice Idea, beats my serial port link dumping random characters :o)
to a PC (hey why do I run out of serial ports on my pc ;o)

Regards,

Kat.





____________________________________________________________________________
/"\   ASCII Ribbon Campaign  |        K.A.Q. Electronics
\ / - NO HTML/RTF in e-mail | Software and Electronic Engineering
X  - NO Word docs in e-mail  |      Perth Western Australia
/ \                                            |        Ph +61 419 923 731
____________________________________________________________________________

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email @spam@listservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


2001\12\26@224420 by Alexandre Domingos F. Souza

flavicon
face
       Meow! (just though of you this morning, passing near a pet shop, and saw a little kitty, hehehe)

>Mmmmmmmm Nice Idea, beats my serial port link dumping random characters :o)
>to a PC (hey why do I run out of serial ports on my pc ;o)

       The answer? Digiboard 8 port ;o) uauauahahua

       Seriously: I have an 4 port card, I use in my "experiences" - recognized by DOS and works like a charm - all 16550 AFN.


---8<---Corte aqui---8<----

Alexandre Souza
KILLspamtaitoKILLspamspamterra.com.br
http://planeta.terra.com.br/lazer/pinball/

---8<---Corte aqui---8<----

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\12\26@224625 by myke predko

flavicon
face
Dave Dribin asked...

> Do you give out $2.56 for errors? :) I'm sure I will be working
> through more examples in the upcoming weeks, so I'll keep my eye out.

Hmmm...  That's not a bad idea.

Having said this, I do know of one other interesting mistake in
"Experiments".  Kind of subtle and you will have to go through the code and
compare it to the comments (and diagrams) in the text.

> Thanks for the open arms of others on this list, too!  It's been years
> since I've done any hardware work, and sometimes its a bit
> intimidating to get back into it.  It's amazing how much you forget if
> you don't practice it.

I feel like I relearn that every day.

Good luck and let me know what you find and if you have any suggestions to
make the book better.

myke

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservspamBeGonespammitvma.mit.edu with SET PICList DIGEST in the body


2001\12\27@012941 by Dave Dribin

flavicon
face
On Wed, Dec 26, 2001 at 10:46:44PM -0500, myke predko wrote:
> Dave Dribin asked...
>
> > Do you give out $2.56 for errors? :) I'm sure I will be working
> > through more examples in the upcoming weeks, so I'll keep my eye out.
>
> Hmmm...  That's not a bad idea.

I must confess that this isn't my idea.  Donald Knuth started that for
errors in The Art of Computer Programming (search for "Rewards"):

 http://www-cs-faculty.stanford.edu/~knuth/taocp.html

> Good luck and let me know what you find and if you have any suggestions to
> make the book better.

Thanks, and I must say, overall it is a great book.  Keep up the good
work!

-Dave

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestEraseMEspamspam_OUTmitvma.mit.edu


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...