Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronic Content > Electronic Books

Notices


Electronic Books Recommended books of interest to any electronic enthusiasts.

Reply
 
LinkBack Thread Tools Display Modes
Old 28th April 2008, 10:45 AM   (permalink (permalink))
Default

Quote:
Originally Posted by ex-navy
Thanks for the answer on the EQUals.

Is it common practice to include these statements in code?
No it's not.

Quote:

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?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply With Quote
Old 28th April 2008, 11:03 AM   (permalink (permalink))
Default

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
__________________
We learn by example and by direct experience because there are real limits to the adequacy of verbal instruction. Malcolm Gladwell

www.olson-engineering.com

Last edited by ex-navy; 28th April 2008 at 11:06 AM.
ex-navy is offline  
Reply With Quote
Old 28th April 2008, 11:12 AM   (permalink (permalink))
Default

Quote:
Originally Posted by ex-navy
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.!!!

EDITED:
The extension of the abbreviation EQU, is not EQUals, its EQUATES
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/

Last edited by ericgibbs; 28th April 2008 at 11:21 AM.
ericgibbs is offline  
Reply With Quote
Old 28th April 2008, 11:17 AM   (permalink (permalink))
Default 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.
__________________
We learn by example and by direct experience because there are real limits to the adequacy of verbal instruction. Malcolm Gladwell

www.olson-engineering.com
ex-navy is offline  
Reply With Quote
Old 28th April 2008, 11:25 AM   (permalink (permalink))
Default

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
__________________
We learn by example and by direct experience because there are real limits to the adequacy of verbal instruction. Malcolm Gladwell

www.olson-engineering.com
ex-navy is offline  
Reply With Quote
Old 28th April 2008, 11:42 AM   (permalink (permalink))
Default

Quote:
Originally Posted by ex-navy
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.!
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is offline  
Reply With Quote
Old 28th April 2008, 01:25 PM   (permalink (permalink))
Default

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.
Pommie is offline  
Reply With Quote
Old 28th April 2008, 01:33 PM   (permalink (permalink))
Default

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???
__________________
We learn by example and by direct experience because there are real limits to the adequacy of verbal instruction. Malcolm Gladwell

www.olson-engineering.com

Last edited by ex-navy; 28th April 2008 at 01:44 PM.
ex-navy is offline  
Reply With Quote
Old 28th April 2008, 01:48 PM   (permalink (permalink))
Default

Quote:
Originally Posted by ex-navy
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 by Pommie; 28th April 2008 at 01:54 PM.
Pommie is offline  
Reply With Quote
Old 29th April 2008, 03:45 AM   (permalink (permalink))
Default

Quote:
Originally Posted by Pommie
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.
__________________
--- The days of the digital watch are numbered. ---
kchriste is offline  
Reply With Quote
Old 29th April 2008, 04:26 AM   (permalink (permalink))
Default

Yes, my bad. It would have been better to say "This bank switching was replaced on the 18 series chips.", meaning the RP0 type switching.

Mike.
Pommie is offline  
Reply With Quote
Old 29th April 2008, 07:19 PM   (permalink (permalink))
Default

As the book will take ages to create I was thinking of doing something in sections like a newsletter. Something like the old TPUG (Toronto PET Users Group) newsletter.
http://www.tpug.ca/archive/archive.html

Peharps starting with about 4 pages and hopefully will grow over time.
JPUG (Junebug PIC Users Group)
Attached Files
File Type: pdf JPUG #1 cover.pdf (148.9 KB, 18 views)
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now  
Reply With Quote
Old 30th April 2008, 06:40 AM   (permalink (permalink))
Default

hi Bill,
IMO, this parallel approach is a much better idea.

In this way contributors could submit to 'you' articles of say, upto 6 pages on their specialised subject for publication on the forum.

This should get the information available for use by readers far quicker than waiting for a 'book' to be released,,, which will most likely be out of date by the time it is completed.

The writers could also update/upgrade their sections in the future, as required.

We are always proposing to students that the 'modular' way of programming is the way to go, so why not go modular with the book.?

Regards
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/

Last edited by ericgibbs; 30th April 2008 at 06:43 AM.
ericgibbs is offline  
Reply With Quote
Old 30th April 2008, 01:18 PM   (permalink (permalink))
Default

I agree, every time I get a "new" PIC book it's either full of errors or out of date. A newsletter can also be presented in any order. Code / hardware snippets, contributions, ideas. Like the fourms here but collected and saved in a PDF format. I'll post them here and on my site so they can be found with ease. Now all I need is to gather some articles and there are plenty here.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now  
Reply With Quote
Old 11th May 2008, 03:36 PM   (permalink (permalink))
Default Jpug

Bill,

I think that's an excellent idea. A newsletter would provide a modular approach, much like lessons.

Start off with newbie discussions and work your way up. It's like an interactive book with articles submitted by other users.

I tend be the type that would like to print a pdf lesson for future reference instead of trying to find it in my bookmarks.
__________________
We learn by example and by direct experience because there are real limits to the adequacy of verbal instruction. Malcolm Gladwell

www.olson-engineering.com
ex-navy is offline  
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Latest
Electronic Systems (General Electronics) ThermalRunaway Electronic Books 39 4th October 2008 10:56 AM
Visual Basic for Electronics Engineering Applications ThermalRunaway Electronic Books 22 27th August 2008 07:40 PM
High ADC sampling rate PIC, 18F needed? bananasiong Micro Controllers 24 28th October 2007 12:13 PM
Need some help with a code provided by ATMEL ikalogic Micro Controllers 1 23rd January 2007 02:45 PM
Recomended book for the Electronics "newb" windozeuser General Electronics Chat 1 21st July 2005 07:04 PM



All times are GMT. The time now is 04:33 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.