Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Would you like to write a PIC book with me?

Status
Not open for further replies.
vdd said:
Would it be easier for an absolute beginner to start with the 16F series? Or is it better to start with the 18F series?

I mean a beginner might be overwhelmed by so much new features the 18F series have.
Don't worry. You won't be overwhelmed. :D I hear that nonsense all the time. :p

All the PICs, from the smallest/oldest to the largest/newest work very much alike. The bigger ones just have more pins, more peripherals/features and often more speed. That doesn't make them harder to use. You only use the features/peripherals you need for the program you're writing, no matter which chip you're using.

Start with any PIC you want to. If possible, start with something popular like the (18F1320), so you have plenty of help (if you need it) available for the chip you're starting out with.
 
Last edited:
This is a great idea I am just starting out in Pic I have just built a project from Maplin which can program 4 chips 8P 14P 18P 28P came with Pic16F 627
I don't know if it is any good or not I feel this book can help me get me started as it is going to up to date.
Project I just built might be out of date.
 
peter5355 said:
This is a great idea I am just starting out in Pic I have just built a project from Maplin which can program 4 chips 8P 14P 18P 28P came with Pic16F 627
I don't know if it is any good or not I feel this book can help me get me started as it is going to up to date.
Project I just built might be out of date.

Does your programmer program the 18F series? If so which ones? 18F1320, 18F4620?
 
18f1320

I learned assembly more than 10 years ago. Forgot most of it.

Bought Bill's Junebug kit, highly recommend the 18F1320.

Why??

I have half of Mike Predko's library of books on assembly and found his method of teaching difficult.

The main problem is the books tend to jump all over the place. Example is 123 PIC Microcontroller Experiments.

I thought I bought a book on assembly only to find out that lesson starts on Page 187.

The first part of the book gets you into C.

For mysefl I find assembly easier.

The book is also based on 16F PICS.

I also have PIC in Practice by D.W. Smith.

Outdated, it's nice to see sample circuits based on the 16F84 which is very good but he jumps right past a Header file for the 16F84 to a program example.

To me that's like skipping the first few chapters of a book and trying to understand the rest.

I used to teach electronics, Bill, learn from your audience, find out what they find most difficult about learning, then design a laymans book based on what you hear from them.

Keep it simple.

Most times what we think is very simple is the most confusing. Take a look at how most programmers teach Linux.

BTW, what does the following Equate statements mean??

TMR0 EQU 1 ;means TMR0 is file 1
STATUS EQU 3 ;means STATUS is file 3
PORTA EQU 5 ;means PORTA is file 5


What does he mean by "file 1", "file 3", "file 5"??
 
I'm actually sitting down and writing a some sample programs (in assembler) for the book.
I would like to cover three languages plus some hardware.
Assembler (MPASM)
BASIC (Swordfish SE)
C (C18 SE)
All are the free demo versions, actually since Swordfish SE has a 256 byte ram limitation it's perfect for the 18F1320 (256bytes RAM)
 
I think it would be cool to have 3 code examples of each project

Small projects all written in the 3 languages that you suggested:

Assembly
Swordfish Basic
C18

Almost like an opensource book based on the 18F1320
 
BTW, what does the following Equate statements mean??
TMR0 EQU 1 ;means TMR0 is file 1
STATUS EQU 3 ;means STATUS is file 3
PORTA EQU 5 ;means PORTA is file 5
Read EQU as EQUals.
So the statement, TMR0 EQU 1, means make the label TMR0 equal to 1. This is because the TMR0 register resides at address location 1. The STATUS register resides at address location 3, etc.
These equate statements allow us to refer to the registers with a name rather than a number (address). People are better with names.
 
I agree that would be an excellent idea.

The 18F1320 is not much different than any other 18F PIC, what you learn on it would be easy to migrate to the larger more complex PICs like the 18F4620 and the amazing 18F67J60 (Ethernet)
 
Thanks for the answer on the EQUals.

Is it common practice to include these statements in code?

The reason I ask is that I don't see these used often in other peoples source code. I see it in book examples and wonder if the book was just outdated and upgrades in technology do not require it anymore.

Maybe the author recommends it so as to demonstrate "proper" coding???

Thanks again, very helpful
 
ex-navy said:
Thanks for the answer on the EQUals.

Is it common practice to include these statements in code?

No it's not.

The reason I ask is that I don't see these used often in other peoples source code. I see it in book examples and wonder if the book was just outdated and upgrades in technology do not require it anymore.

Maybe the author recommends it so as to demonstrate "proper" coding???

No, it's very poor practice, all the standard EQUates are defined in the include file supplied by MicroChip - just add it to the top of the source.

I can only imagine such practice comes from people whom either don't know better, or are used to non-MicroChip assemblers?.
 
Thanks Nigel,

So, when I use MPLAB IDE and create a project, the include file associated with the PIC I select already contains this data??

Actually the author of the book I purchased to "re-learn" teaches the reader to always include this in the header of all source code written and the book is based on the 16F84 chip. So he certainly is accustomed to the Microchip product line as he also shows how to use MPLAB IDE v6.30
 
Last edited:
ex-navy said:
Thanks Nigel,

So, when I use MPLAB IDE and create a project, the include file associated with the PIC I select already contains this data??

Actually the author of the book I purchased to "re-learn" teaches the reader to always include this in the header of all source code written and the book is based on the 16F84 chip. So he certainly is accustomed to the Microchip product line as he also shows how to use MPLAB IDE v6.30

hi exnavy,
Look in this folder on your hard drive.
C:\Program Files\Microchip\MPASM Suite\Template\Code

These are templates produced by microchip, I would suggest you use the one related to your PIC when writing programs.

Interesting what you said about 'that' micro book , I too bought it some years ago, its quite useless.!!!:rolleyes:

EDITED:
The extension of the abbreviation EQU, is not EQUals, its EQUATES
 
Last edited:
Another good reason for Bill to write a book

Bill,

As I can see from the books that I have purchased, (in excess of $200) and knowing and teaching electronics in the Navy, there is a lack of reference to the tools that are needed to start and how to use these tools.

For instance:

I bought and built a Junebug, not a problem to follow your schematics and love your Google sketchups, by the way;

Then I needed to discover how to code using the MPLAB IDE. This was a huge learning curve, as the MPLAB manual is good, however; knowing what programmer/debug tool to select, do I need linker files or not, how to build, how to run, where is a list of errors, etc etc.

Establish base lines first.

List what tools will be used in this particular project:

Example:

MPLAB IDE v8.0
Junebug
USB cable
Notepad or similiar

I find that there is alot of expertise here, alot of pros and cons in using Assembly, Swordfish, C18, blah blah blah, but a newbie can be "steered" all over the place by members using other IDE's, programmers, languages, hardware, etc.

Build it and I will buy it.
 
Thanks Eric,

Yes, I discovered that it is Equates. I did not understand at first.

Can someone also explain if I am correct in assuming the following:

Consider an LED with its cathode to ground.
It's anode is connected via a current limiting resistor on pin RA0

If I want to illuminate the LED, using assembly, I first establish PORTA as outputs by writing 8 zeroes to TRISA?

The 8 pins on PORTA correspond to pins RA7:RA0

movlw b'00000000'
movwf TRISA

I then set bit PORTA, RA0 ;illuminate LED

BSF PORTA,RA0
 
ex-navy said:
Thanks Eric,

Yes, I discovered that it is Equates. I did not understand at first.

Can someone also explain if I am correct in assuming the following:

Consider an LED with its cathode to ground.
It's anode is connected via a current limiting resistor on pin RA0

If I want to illuminate the LED, using assembly, I first establish PORTA as outputs by writing 8 zeroes to TRISA?

The 8 pins on PORTA correspond to pins RA7:RA0

movlw b'00000000'
movwf TRISA

I then set bit PORTA, RA0 ;illuminate LED

BSF PORTA,RA0

hi,
I would suggest that you look thru Nigels tutorials, ref LED's and other topics.
The web link appears under his name on his posts...:)

You can cut/paste his code into your learning curve.!
 
Whilst you shouldn't include a list of equates for the special function registers, you should equate other things. This makes the code much easier to read.

Code:
BufferLength	equ	.64
Cr		equ	.13
Esc		equ	.27
BaudRate	equ	.19200

A lot of people now think that you should use #define instead.

Mike.
 
Yes, I just read Nigels first 5 tutorials and now see why EQU statements are important

LEDPORT EQU PORTB
LEDTRIS EQU TRISB

So, the #define statement is the same as the EQU??

I also see by your example that you use .64 which I assume means decimal 64.

In Nigels tutorials he uses d'250'

So one could use movlf .250??

One more question that has me stumped as I don't see it often in code is the STATUS RPO

Setting the RPO bit of the Status Register selects BANK 0. By meaning BANK 0, does that mean BANK 0 is a memory page??
BANK 1 is the other memory page (allocation page??)

I don't see this in documentation for the 18F1320, so is it used anymore in the newer PICs???
 
Last edited:
ex-navy said:
Yes, I just read Nigels first 5 tutorials and now see why EQU statements are important

LEDPORT EQU PORTB
LEDTRIS EQU TRISB

So, the #define statement is the same as the EQU??

#define is better for things that are not numbers,
Code:
#define LED1    PORTB,3

        bsf     LED1
;is the same as
        bsf     PORTB,3

The two strings are simply swapped at assembly time.

Edit, you added a bit.:) You can use movlw .250. Setting bit RP0 selects bank 1, clearing RP0 selects bank 0. These banks are banks of 128 bytes of ram (SFRs in Microchip speak). This bank switching was removed on the 18 series chips.

Mike.
 
Last edited:
Pommie said:
This bank switching was removed on the 18 series chips.
No, there is still bank switching on the 18F series chips. The difference is the inclusion of the "access bit" for instructions so that you don't have to do as much bank switching as you did in the 16F and lower PICs.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top