Searching \ for '[PIC]:New to this world' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'New to this world'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]:New to this world'
2000\09\15@173325 by Barry Gershenfeld

picon face
This is actually my second attempt at becoming a PIC hacker.  Six weeks
ago was my first attempt.  I succeeded at putting a counting sequence
out port D.  At that time I had big arguments with the C compiler over
how to set the port to output (Eventually did it one bit at a time!)
Since I'm trying the MPLAB tutorial, I'm sticking to assembler today.
At least that removes one layer of obfuscation.

Equipment - MPLAB 4.12,  ICD, and 16F874 handbuilt on a board (takes
the place of the "demo" board.  This '874 actually works, as I was
able to get the port-counter to run from power-up without the ICD
attached.

Problem 1.
MPLAB-ICD says it's set for 16F877 and I can't change it.  I thought
maybe that was a setting that would work for all 87x but when I
give it code from a 16F874 compile it complains.

Solution 1.
Upgrade MPLAB to current 5.11 version.  Apparently a free download.
Now I have more choices for processor.

Problem 1.5
The new software requires a firmware upgrade to the ICD board!  This
one's not free but the resulting upgrade is apparently flash downloadable.
So until I get it I won't know how many of the following will be
answered by that fix.

Problem 2.
When I reset the processor it does not go  to PC=0.  It seems to go
to the location pointed to by 0.  Maybe it's supposed to do that
(It's a pretend debugger, after all)

Problem 3.  The register used in the programming example (MPLAB
tutorial) won't update in the debug display.

Solution 3.  Location 0C is a real register, on this chip, anyway.
So I changed it to 21 which is general purpose.  Does Microchip
ever make mistakes? (Large grin)

Problem 4. Now I see a register at A1, not 21, being updated.  This
may be one of those "get the firmware upgrade" things.

Problem 5.  I don't know where the program is running.  Is it on
the ICD board in that PIC or is it on the board I built?  The
reason I ask, besides the upredictable behaviors, is that I can
hold the reset switch down and still step the program.  Where
I come from that isn't normal.  Maybe the PIC is edge triggered.
Maybe a reset doesn't clear everything and send it back to 0.
Mabye I should crack open the datasheet and do some more
reading :-)

Any advice is appreciated.  There will more questions, no doubt...

Barry

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\09\16@130043 by James Newton

face picon face
#5 The programming is running on the PIC on the board that you built. When
in debug mode via the ICD, the reset does not have the same effect that it
would in normal operation.

#2 I can't really comment on the other issues, (not being a very regular ICD
user - I like Scenix SX chips and the SXKey) but I know that a "reset
vector" ( a jump to the ICD code loaded into the target chip during
programming ) is loaded at the beginning of memory, so the start of your
code is not at 0.

#4 Banking. Just look up banking. Actually, combined with paging, that is
the answer to a good 90% of the problems people have with PICs.

James Newton
spam_OUTjamesnewtonTakeThisOuTspamgeocities.com
1-619-652-0593 phone

{Original Message removed}

2000\09\18@131621 by Dan Michaels

flavicon
face
Barry Gershenfeld wrote:
>This is actually my second attempt at becoming a PIC hacker.  Six weeks
>ago was my first attempt.  I succeeded at putting a counting sequence
>out port D.  At that time I had big arguments with the C compiler over
>how to set the port to output (Eventually did it one bit at a time!)
>Since I'm trying the MPLAB tutorial, I'm sticking to assembler today.
>At least that removes one layer of obfuscation.
>
>Equipment - MPLAB 4.12,  ICD, and 16F874 handbuilt on a board (takes
>the place of the "demo" board.  This '874 actually works, as I was
>able to get the port-counter to run from power-up without the ICD
>attached.
.........
>Any advice is appreciated.  There will more questions, no doubt...
>


Barry,

It may be too late, but I made this point in another thread
last week - and actually got **2** other piclisters to agree with
the logic in it ---

It is probably easier and quicker to get up to speed with PICs
if you don't jump straight into the deep end of the pool with lead
weights already tied around your neck. [mixed metaphors - sorry].

Might be better to use a cheap programmer, text editor/assembler
rather than IDE, and a PIC 16F84 to begin with. Then go to the
more complex '87x type chips, after basic things are working well
on the '84.

They adopted the "learning curve" - graded progression - method
of education in schools for good reason.

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2000\09\18@141436 by Barry Gershenfeld

picon face
It is kind of too late, but isn't the 16F84 very much like the
16F874?  If I were to ignore the presence of the added fancy
stuff, could I pretend to be programming the '84?

I'm new to PICs but not to embedded.  I have worked with
other 8-bit processors, done a little x86 assembly language
as well, RS232 is one of my strong areas, I know how to
use a scope and ICE, but I also know how to not need them by
application of software techniques.

I saw the posts you were referring to and I almost asked
this question then:  Is it about the PICs is it about
the combination of embedded programming and I/O goodies
in general.  Because if it's about the PICs then I should
heed your advice.  If its about the combination of all
stuff going on, I may be able to handle it.

Heh...the project's already in the pipe, so it's not like
I have a choice :-)   I intend to bring it up a piece
at a time, though.   Thanks for the advice.

{Quote hidden}

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


2000\09\18@144438 by pandersn

flavicon
face
Barry:

I really agree with Dan......I have not been using PICs long......took it a
step at a time. Actually started with the PICs that came with the PICDEM
board, an eraser, and did a lot of single stepping within MPLAB....so I
could see what was happening.

Then I graduated to the 16F84....no more prom erasing....and MPLAB worked
fine with that.  Now worked my way up to the capture/compare stuff on the
16F873.

HOWEVER, it really is worth while working with timer0 and having to cound
cycles, then appreciate timer1 later.

I think the biggest area where newbies fail is in configuration of the
part. I certainly did, burning time until I realized that the ADCON is
defaulted ON.......!@#$!@#$!@#$

Now I ALWAYS read the spec sheets before starting with a new (to me) chip
#.

But it's fun!  :)      Phil Anderson..

Good luck!






On Monday, September 18, 2000 11:53 AM, Dan Michaels
[SMTP:EraseMEoricomspam_OUTspamTakeThisOuTLYNX.SNI.NET] wrote:
{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2000\09\18@144633 by pandersn

flavicon
face
Just know that if you are NOT going to use the ADCON on the 16F873, then
turn it off. Since teh 16F84 doesn't have the ADCON, ya they are different.

Phil

On Monday, September 18, 2000 1:05 PM, Barry Gershenfeld
[SMTP:KILLspambarryKILLspamspamZMICRO.COM] wrote:
{Quote hidden}

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


2000\09\18@144842 by Dan Michaels

flavicon
face
wrote:
>It is kind of too late, but isn't the 16F84 very much like the
>16F874?  If I were to ignore the presence of the added fancy
>stuff, could I pretend to be programming the '84?
>
>I'm new to PICs but not to embedded.  I have worked with
>other 8-bit processors, done a little x86 assembly language
>as well, RS232 is one of my strong areas, I know how to
>use a scope and ICE, but I also know how to not need them by
>application of software techniques.
...............


All in all, sounds like you are already on 2rd or 3rd base,
rather than at home plate trying to figure out which end of
the bat points north [to use additional stupid metaphors].

So, it probably won't be all that difficult to figure out what
to ignore on the '87x initially. Just ignore all the code
paging and memory bank stuff, the majority of registers in
the memory map, beyond the first few - [just make sure they
are *all* initialized properly - he, he], read up enough about
LVP, code protection, and the other configuration bits that
you have a good feel for the bootup state of the chip, don't
get too involved with the dozen-odd peripherals except maybe
one at a time [RS-232 is good place to start], pay special
attention to the setting of the OPTION register, get "something"
working properly before you try interrupts, don't use the WDT
initially, make sure you choose the correct internal oscillator
for your xtal, read the section about correct reset cktry design
and don't put a large cap directly on the /MCLR pin, watch
out for MPLAB quirks because there are more piclist questions
about this than any other subject, don't try using the internal
EEPROM or debug mode too soon, and yes, you'll find "the 16F84
is very much like the 16F874".

[hmmm, hope I didn't leave anything out!!].

hope this helps,
- Dan Michaels
Oricom Technologies
===================

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


2000\09\18@150131 by Dan Michaels

flavicon
face
Phil Anderson wrote:
..........
>HOWEVER, it really is worth while working with timer0 and having to cound
>cycles, then appreciate timer1 later.
..........


Oh yeah, Timer0, the most "basic" timer every created, and the
only one present in 16F84. There must be 2000 piclist threads with
questions on how to just it. How on earth can you get into so
much trouble so many ways with such a simple register? Beats
me - he, he.

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


2000\09\18@150339 by M. Adam Davis

flavicon
face
I don't believe the 16f8xx series would be any more difficult to understand and
use than the 'f84.  I started out with the 'C84 (a long time ago indeed), but if
the F8xx were available I would have started there.

In either case it is best to start out with a working program, whether it blinks
an LED or whatever.  I needed one to start on the C84, and I believe a beginner
or an experienced user from another microcontroller would need one for the f8xx
now.  There was plenty to ignore on the C84 then, and there's not too much more
to ignore in this case.

So I wouldn't worry about it too much.

-Adam

Barry Gershenfeld wrote:
{Quote hidden}

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


2000\09\18@151749 by Dan Michaels

flavicon
face
Adam Davis wrote:
...........
>
>In either case it is best to start out with a working program, whether it
blinks
>an LED or whatever.  I needed one to start on the C84, and I believe a beginner
>or an experienced user from another microcontroller would need one for the f8xx
>now.  There was plenty to ignore on the C84 then, and there's not too much more
>to ignore in this case.
>

Bingo, best advice of all comes from Adam ------

====================================================================
Item 1 - regardless of the processor, write a simple program, get it
to work, bootstrap off of that.
====================================================================

For another programmer-from-hell story - I once had a guy doing some
part-time programming for me. He was more interested in getting
married in a month, and getting some $$$ for his honeymoon, than in
doing a good job. He spent several weeks writing some C code, about
10 or 20 pages, with multiple nested "while()" loops. Said it was
going along fine. Then he brought it in, and plunked it down, the
day before he was leaving town. [I'm sure you can see all the
potential disasters present in this scenario].

Well, turns out he never once even compiled the code. It had dozens
of syntax errors - just for a starter. My other programmers said
it was too much of a disaster to even look at. Morale of the story
- see item 1 above.

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


2000\09\18@184955 by Barry Gershenfeld

picon face
>In either case it is best to start out with a working program, whether it
blinks
>an LED or whatever.  I needed one to start on the C84, and I believe a beginner
>or an experienced user from another microcontroller would need one for the f8xx
>now.  There was plenty to ignore on the C84 then, and there's not too much more
>to ignore in this case.
>
>So I wouldn't worry about it too much.
>
>-Adam

I appreciate all the comments and encouragements from the wizards
of the list.  I think some of you might not have seem my original
message (see the Friday comment) so I will repeat the relevant
part:

"This is actually my second attempt at becoming a PIC hacker.  Six weeks
ago was my first attempt.  I succeeded at putting a counting sequence
out port D.  At that time I had big arguments with the C compiler over
how to set the port to output (Eventually did it one bit at a time!)
Since I'm trying the MPLAB tutorial, I'm sticking to assembler today.
At least that removes one layer of obfuscation."

So I have the "start" part.  And have been through the bit with
config bits and oscillator settings and finding out they don't
take effect until you program the part!

Now I'm trying to get reg. 21 to show up at 21 and not A1.  I found
the status register can re-bank that, but:
 - I can't seem to change the status register
 - The status register appears in four places but not with the same value.
 - It's not the values you would think you'd see.

But I'm going to keep reading and also wait for that firmware update
before making a scene about it.  I'm bound to run into a lot more
of that.

Here's a question though:  Is the reset state generally usable or
should I not trust any of the registers and therefore write init
values to each and every one?  I don't think I've seen that kind
of code here so I'm thinking 'no.'  But I don't want to get
caught...

Barry

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


2000\09\18@195052 by Dan Michaels

flavicon
face
Barry Gershenfeld wrote:
..........
>So I have the "start" part.  And have been through the bit with
>config bits and oscillator settings and finding out they don't
>take effect until you program the part!
>

Those are burned in during programming, and cannot be changed
afterwards - at least not on the non-'87x parts.
===================


>Now I'm trying to get reg. 21 to show up at 21 and not A1.  I found
>the status register can re-bank that, but:
>  - I can't seem to change the status register
>  - The status register appears in four places but not with the same value.
>  - It's not the values you would think you'd see.
>

If true, your code is probably wrong.

One thing you will notice is that the instruction opcodes
generally show the same value for 21h as for A1h. 0010'0001
versus 1010'0001. The difference 80h is the difference between
register bank 0 and 1. Which register is selected depends upon
status.rp0 setting - [plus, on the '87x you also have to worry
about rp1]. This goes back to the earlier chips. [welcome to the
deep end, due].
===============


>
>Here's a question though:  Is the reset state generally usable or
>should I not trust any of the registers and therefore write init
>values to each and every one?  I don't think I've seen that kind
>of code here so I'm thinking 'no.'  But I don't want to get
>caught...
>


Some people use the bootup values shown in the D/S, but the more
compulsive types [like me] "always" set every relevant register
to specific values in the first lines of code.

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


2000\09\18@204525 by Tony Nixon

flavicon
picon face
> >Now I'm trying to get reg. 21 to show up at 21 and not A1.  I found
> >the status register can re-bank that, but:
> >  - I can't seem to change the status register
> >  - The status register appears in four places but not with the same value.
> >  - It's not the values you would think you'd see.
> >

The lower 3 bits of the STATUS may not chnge the way you want them to. C
DC and Z

That is because they get altered as the result of instructions.

For example

You would think that

       clrf STATUS
       movf STATUS,W

would result in W = 0, but in fact it will = 4 because the Z bit will be
set.

You can totally clear the STATUS register by using

       clrw
       movwf STATUS

You should be able to change the STATUS register from any RAM bank, as
you have mentioned. Are you using your own RAM address definitions? If
so do you have STATUS defined as

STATUS equ 3h

> One thing you will notice is that the instruction opcodes
> generally show the same value for 21h as for A1h. 0010'0001
> versus 1010'0001. The difference 80h is the difference between
> register bank 0 and 1. Which register is selected depends upon
> status.rp0 setting - [plus, on the '87x you also have to worry
> about rp1]. This goes back to the earlier chips. [welcome to the
> deep end, due].
> ===============

Even deeper, consider the IRP bit for indirect addressing on chips with
4 banks of RAM.

And deeper still, using PCLATH to modify the PC over multiple ROM pages.

Probably at the deepest, using PCLATH to modify the PC over multiple ROM
pages while trying to access different RAM pages for data transfer.

In the twilight zone, is forgetting the settings later on.

{Quote hidden}

I think it's a personal thing driven by experience. You can, but you
probably don't have to.

If you get away with it, you won't, if you get bitten, you will.

Setting something like 40 special function registers in a 16F877 may be
a bit of overkill.

It would probably be beneficial if a brownout was detected.

--
Best regards

Tony

ICmicro's
http://www.picnpoke.com
salesSTOPspamspamspam_OUTpicnpoke.com

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


2000\09\19@040515 by o-8859-1?Q?K=FCbek_Tony?=

flavicon
face
part 1 1317 bytes content-type:text/plain; charset=iso-8859-1 (decoded quoted-printable)

Hi,

Barry Gershenfeld wrote:
>>
>>Here's a question though:  Is the reset state generally usable or
>>should I not trust any of the registers and therefore write init
>>values to each and every one?  I don't think I've seen that kind
>>of code here so I'm thinking 'no.'  But I don't want to get
>>caught...
>>

Dan Michaels replyed:

>Some people use the bootup values shown in the D/S, but the more
>compulsive types [like me] "always" set every relevant register
>to specific values in the first lines of code.

I second that, although it might not be needed, you always know
that this is not the place to start looking when thing go wrong :-).
Included ther's a few 'scratch' snippets from a while ago, that might be
useful
init ram, ports, uart, i2c etc.
( and yes setting SFR's via FSR IS not advicable i know ). Note this is
not relocatable code ( i'm playing with that right now ).

Have fun,

BTW I only did one project on the 16F84 before i went to the 16F87x
and since I have never looked back.

/Tony






Tony Kübek, Flintab AB            
²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²
E-mail: KILLspamtony.kubekspamBeGonespamflintab.com
²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²


part 2 24618 bytes content-type:application/octet-stream; name="snipp.asm" (decode)

part 3 184 bytes
--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's


2000\09\19@042627 by o-8859-1?Q?K=FCbek_Tony?=

flavicon
face
part 1 281 bytes content-type:text/plain; charset=iso-8859-1 (decoded quoted-printable)

Hi,
forgot to include some macros,

/Tony


Tony Kübek, Flintab AB            
²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²
E-mail: EraseMEtony.kubekspamEraseMEflintab.com
²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²


part 2 9182 bytes content-type:application/octet-stream; name="macro.asm" (decode)

part 3 184 bytes
--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's


2000\09\19@075739 by Andy Jancura

picon face
{Quote hidden}

Barry,

if you have done some works with other controlers, then the ideal one will
be the new PIC18C. It has similar assembler to other controlers like
Motorola or Intel and it will be available in very different variants. And
are pin compatible to current PIC's 16C7x.

The classics of PIC's, the 16C84 is good for learning of programming
techniques, as what you learn is good on every other chips. Not only on PIC.

The problem is probably the hardware peripherals. Here you have to read all
the datasheets. Thats all.

For starting with PIC 16C74 is good to get one working file. I recommend you
the PICUSART.ASM. Its really good commented and it work with serial ports.
You see some typical problems with PIC. Its in archive.

Andrej





_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's


2000\09\19@085003 by Olin Lathrop

flavicon
face
> Here's a question though:  Is the reset state generally usable or
> should I not trust any of the registers and therefore write init
> values to each and every one?  I don't think I've seen that kind
> of code here so I'm thinking 'no.'  But I don't want to get
> caught...

The reset state is well documented, but I usually initialize everything that
my code requires set in a particular way.  This means that a "software
reset" can be performed simply by GOTO 0, which I've occasionally found
handy.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, TakeThisOuTolin.....spamTakeThisOuTcognivis.com, http://www.cognivis.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's


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