Editing A Really Basic Guide to the PIC Microprocessor and BoostC

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 3: Line 3:
  
  
Draft, not quite done, but should be useful even at this state -- still fixing formatting, adding images........
+
Draft not ready
  
  
Line 42: Line 42:
 
I suppose an input/output port is a peripheral, but normally the term is used for something more complicated. A counter/timer is one example. A counter is connected to some source ( a pin for example ) and each time the pin changes from a 0 to a 1 the counter increase by 1. Some counters are 8 bit, some 16 bits( this is the number of bits for the highest number the counter can count to )..  
 
I suppose an input/output port is a peripheral, but normally the term is used for something more complicated. A counter/timer is one example. A counter is connected to some source ( a pin for example ) and each time the pin changes from a 0 to a 1 the counter increase by 1. Some counters are 8 bit, some 16 bits( this is the number of bits for the highest number the counter can count to )..  
  
Other peripherals are: PWM outputs ( pulse width modulation ) Serial communications, Analog to digital converters.
+
Other peripherals are: PWM outputs ( pulse with modulation ) Serial communications, Analog to digital converters.
  
 
All the peripherals discussed so far are built right into the chip, they are called internal peripherals, peripherals can also be outside the PIC chip, these are external peripherals.  
 
All the peripherals discussed so far are built right into the chip, they are called internal peripherals, peripherals can also be outside the PIC chip, these are external peripherals.  
Line 54: Line 54:
 
A PIC that is not connected to something is pretty much useless. It could be finding the answer to the ultimate question, but how would you know? The more electronics you know the more things you may figure out to connect them to. This tutorial will deal only with the simplest connections.  
 
A PIC that is not connected to something is pretty much useless. It could be finding the answer to the ultimate question, but how would you know? The more electronics you know the more things you may figure out to connect them to. This tutorial will deal only with the simplest connections.  
  
=== A LED ===
+
A LED
  
 
A LED is just a small light that lights up with voltages and currents that work pretty well with the PIC. Here are two typical circuits:
 
A LED is just a small light that lights up with voltages and currents that work pretty well with the PIC. Here are two typical circuits:
  
[[Image:LED1.jpg | LED Circuit]]
 
  
  
And the second circuit:
 
  
[[Image:LED2.jpg | LED Circuit]]
 
  
  
Line 70: Line 67:
 
VPLUS_VDD is the positive power to the PIC, typically 5 volts.
 
VPLUS_VDD is the positive power to the PIC, typically 5 volts.
  
=== A Push Button Switch ===
+
A Push Button Switch
  
 
Normally used with a pull up ( or down ). The switch is often a single pole momentary switch, that is the switch is closed only when it is pushed, it pops back open when the button is released. Many keyboards or keypads are arrays of push button switches. Some circuits are as follows:
 
Normally used with a pull up ( or down ). The switch is often a single pole momentary switch, that is the switch is closed only when it is pushed, it pops back open when the button is released. Many keyboards or keypads are arrays of push button switches. Some circuits are as follows:
  
  
[[Image:PBPullDown.jpg | Push Button]]
+
 
  
  
Line 91: Line 88:
  
 
Using a transistor to drive a LED ( also useful for other components which use more power than a PIC output port can supply, or to lessen the load on the PIC )
 
Using a transistor to drive a LED ( also useful for other components which use more power than a PIC output port can supply, or to lessen the load on the PIC )
 
 
[[Image:LEDTrans.jpg | Transistor Drive ]]
 
  
  
Line 104: Line 98:
 
VPLUS_VDD is the positive power to the PIC, typically 5 volts.
 
VPLUS_VDD is the positive power to the PIC, typically 5 volts.
  
=== The Crystal Clock Circuit ===
+
 
 +
The Crystal Clock Circuit
  
 
The PIC has two pins that we are going to connect to a 4 mega Hz crystal. This will make the PIC run at 4 mega Hz. There are other ways to “clock” the PIC, but a nice feature of a crystal is that the frequency is very precise, usually a small fraction of a percent, so you can use the PIC for quite precise timing. Here is the circuit.
 
The PIC has two pins that we are going to connect to a 4 mega Hz crystal. This will make the PIC run at 4 mega Hz. There are other ways to “clock” the PIC, but a nice feature of a crystal is that the frequency is very precise, usually a small fraction of a percent, so you can use the PIC for quite precise timing. Here is the circuit.
  
[[Image:Crystal.jpg | Crystal]]
+
 
  
 
CRYSTAL_PIN_1 The PIC pin for the crystal connection OSC1 pin xx on the PIC877
 
CRYSTAL_PIN_1 The PIC pin for the crystal connection OSC1 pin xx on the PIC877
Line 120: Line 115:
 
GND Ground, or 0 volts, sometimes called Vss.
 
GND Ground, or 0 volts, sometimes called Vss.
  
=== Reseting the Processor, MCLR ===
+
 
 +
Reseting the Processor, MCLR
  
 
A final circuit can be used to reset the processor – this is basically making it start at the beginning of the program. This is done with a pin that is set to 0 to reset, left at 5 volts to let the processor run. You can leave out the pushbutton if you do not want to use the reset, but keep the resistor in the circuit or the processor might reset when you least expect it.
 
A final circuit can be used to reset the processor – this is basically making it start at the beginning of the program. This is done with a pin that is set to 0 to reset, left at 5 volts to let the processor run. You can leave out the pushbutton if you do not want to use the reset, but keep the resistor in the circuit or the processor might reset when you least expect it.
  
[[Image:MCLR.jpg | Master Clear]]
 
  
  
Line 135: Line 130:
 
GND Ground, or 0 volts, sometimes called Vss.
 
GND Ground, or 0 volts, sometimes called Vss.
  
== Software: A Beginning Program ==
+
Software: A Beginning Program
  
 
For software we will focus on the C language and in particular on a “lite” and free version from Source Boost. Before beginning this section it would be a good idea to download and install the BoostC compiler. You can find the download page at: http://www.sourceboost.com/Products/BoostC/Download.html A complete list of what you need to both write and run the program is in an appendix at the end of this document.
 
For software we will focus on the C language and in particular on a “lite” and free version from Source Boost. Before beginning this section it would be a good idea to download and install the BoostC compiler. You can find the download page at: http://www.sourceboost.com/Products/BoostC/Download.html A complete list of what you need to both write and run the program is in an appendix at the end of this document.
Line 170: Line 165:
 
Now lets read through the program and add some comments ( I could give you this program with the comments, but if you add the notes yourself it will mean more to you ) First line:
 
Now lets read through the program and add some comments ( I could give you this program with the comments, but if you add the notes yourself it will mean more to you ) First line:
  
  '''#include <system.h>'''
+
#include <system.h>
  
 
( note I will use the font above for all lines in the C source file ) Start all programs with this statement, it adds the contents of the file system.h to your project, and most BoostC programs want this file. It makes the symbolic names ( like portb ) for PortB available to the compiler. To add a note about this to the file start the line with //. So you might add:
 
( note I will use the font above for all lines in the C source file ) Start all programs with this statement, it adds the contents of the file system.h to your project, and most BoostC programs want this file. It makes the symbolic names ( like portb ) for PortB available to the compiler. To add a note about this to the file start the line with //. So you might add:
  
  '''// start all BoostC programs with this include.'''
+
// start all BoostC programs with this include.
  
 
A line like the above is called a comment and is ignored by the compiler, but can give the human reader useful information. Use comments, if you do not even you will not understand your code at a later date.
 
A line like the above is called a comment and is ignored by the compiler, but can give the human reader useful information. Use comments, if you do not even you will not understand your code at a later date.
Line 180: Line 175:
 
By the way note that C is case sensitive, do not change that capitalizations, also there are conventions on capitalization that you should follow, I will mention them later. Now read down to the line:
 
By the way note that C is case sensitive, do not change that capitalizations, also there are conventions on capitalization that you should follow, I will mention them later. Now read down to the line:
  
  '''#pragma DATA _CONFIG, _PWRTE_OFF & _BODEN_OFF & _WDT_OFF & _LVP_OFF & _CPD_OFF & _DEBUG_OFF & _XT_OSC & _CP_OFF'''
+
#pragma DATA _CONFIG, _PWRTE_OFF & _BODEN_OFF & _WDT_OFF & _LVP_OFF & _CPD_OFF & _DEBUG_OFF & _XT_OSC & _CP_OFF
  
 
this line does some set up of the compiler and the chip. There is a section in the manual about this, the are normally called configuration fuses. Setting them up the wrong way can be a real problem, learning all about them can take awhile. Leave them as they are until you learn more. Now the line:
 
this line does some set up of the compiler and the chip. There is a section in the manual about this, the are normally called configuration fuses. Setting them up the wrong way can be a real problem, learning all about them can take awhile. Leave them as they are until you learn more. Now the line:
  
  '''#pragma CLOCK_FREQ 4000000'''
+
#pragma CLOCK_FREQ 4000000
  
 
This tell the compiler how fast your clock will be. For this chip this is the frequency of the crystal you are using. ( we are planning a 4 mega Hz clock and crystal. This is important because the compiler will generate some programs for delaying the computer for a time. To do this it needs to know how fast the clock is.
 
This tell the compiler how fast your clock will be. For this chip this is the frequency of the crystal you are using. ( we are planning a 4 mega Hz clock and crystal. This is important because the compiler will generate some programs for delaying the computer for a time. To do this it needs to know how fast the clock is.
  
  '''void interrupt( void ) {'''
+
void interrupt( void ) {
  
 
this line begins a subroutine that handles processor interrupts ( whatever they are ). For now you will not be using them, but for now leave the code in. If you have an interrupt by some mistake you program will work better with this in.
 
this line begins a subroutine that handles processor interrupts ( whatever they are ). For now you will not be using them, but for now leave the code in. If you have an interrupt by some mistake you program will work better with this in.
Line 196: Line 191:
 
Next look at:  
 
Next look at:  
  
  '''void main( void ) {'''
+
void main( void ) {
  
 
this is the so called main program, when the PIC starts up it starts here. What does this code do? Lets take a look:
 
this is the so called main program, when the PIC starts up it starts here. What does this code do? Lets take a look:
  
  '''//Configure port B
+
//Configure port A
  trisb = 0x00;'''
+
trisa = 0x00;
  
this line sets the control register for port b: called trisb to all 0's ( every bit = 0 ). 0 makes the bit an output bit, that is the pin connected to port pin is an output pin. To find what pins this is on the chip look in the 877 manual The 0x means that the number is expressed in hexadecimal or base 16. You can also use regular decimal, or binary. In binary you can clearly see each bit.
+
this line sets the control register for port a: called trisa to all 0's ( every bit = 0 ). 0 makes the bit an output bit, that is the pin connected to port pin is an output pin. To find what pins this is on the chip look in the 877 manual The 0x means that the number is expressed in hexadecimal or base 16. You can also use regular decimal, or binary. In binary you can clearly see each bit.
 
0x0 is 0b0 in binary or 0b00000000 the last notation showing all 8 bits in the byte.  
 
0x0 is 0b0 in binary or 0b00000000 the last notation showing all 8 bits in the byte.  
  
 
The code continues working through other ports setting them all to output. The code then continues setting up some other configuration stuff that I would rather not explain. Pretty much all this stuff is safe, that is it will not do anything bad. The exception to this is the line:
 
The code continues working through other ports setting them all to output. The code then continues setting up some other configuration stuff that I would rather not explain. Pretty much all this stuff is safe, that is it will not do anything bad. The exception to this is the line:
  
  '''intcon = 0xA0;'''
+
intcon = 0xA0;
  
 
this will turn on the interrupts which we would rather have off. Change it to  
 
this will turn on the interrupts which we would rather have off. Change it to  
  
  '''intcon = 0b0;'''
+
intcon = 0b0;
  
 
this will have the interrupts off. Also fix the comment just above this line so it is correct.
 
this will have the interrupts off. Also fix the comment just above this line so it is correct.
Line 218: Line 213:
 
Now we are almost done: we have next
 
Now we are almost done: we have next
  
  '''while( 1 ) ;'''
+
while( 1 ) ;
  
 
This is a loop that runs forever doing nothing.
 
This is a loop that runs forever doing nothing.
Line 224: Line 219:
 
Change this to:
 
Change this to:
  
  '''while( 1 ) {
+
while( 1 ) {
  }'''
+
}
  
 
This is still a loop that runs forever doing nothing but the difference is that the loop begins at the { and extends to the }. Writing it this way gives us a place to add code to the loop so that it will do something. Note that this is typical for a PIC program to have a loop like this, but normally doing something. Start up, set up, and do something forever. Just a note about a loop if you are not familiar with the term. A loop in a program is a bit like running in a circle, you go around and around. Since the program is written as sequential lines this means we start at some line, the beginning of the loop, work down to a lower line, the end of the loop, and then go back to the beginning of the loop. Most loops ( unless the purpose is just to take up time ) do something each time the loop, perhaps count from 0 to 99. Many loops in fact count just to determine how many times to execute the code in the loop, this may be done to delay the program a bit. At the end of the count they “drop out of the bottom” of the loop.
 
This is still a loop that runs forever doing nothing but the difference is that the loop begins at the { and extends to the }. Writing it this way gives us a place to add code to the loop so that it will do something. Note that this is typical for a PIC program to have a loop like this, but normally doing something. Start up, set up, and do something forever. Just a note about a loop if you are not familiar with the term. A loop in a program is a bit like running in a circle, you go around and around. Since the program is written as sequential lines this means we start at some line, the beginning of the loop, work down to a lower line, the end of the loop, and then go back to the beginning of the loop. Most loops ( unless the purpose is just to take up time ) do something each time the loop, perhaps count from 0 to 99. Many loops in fact count just to determine how many times to execute the code in the loop, this may be done to delay the program a bit. At the end of the count they “drop out of the bottom” of the loop.
  
 
Finally we have the final
 
Finally we have the final
 
+
}
  '''}'''
 
  
 
which ends the routine main, and since main is also where the program starts it ends the whole thing. Also since the loop never ends we never get through this point.
 
which ends the routine main, and since main is also where the program starts it ends the whole thing. Also since the loop never ends we never get through this point.
Line 238: Line 232:
  
 
Now lets add some code to make the LED's blink. There are 2 key ideas for this.
 
Now lets add some code to make the LED's blink. There are 2 key ideas for this.
 +
One you need to change the value of a port back and froth from 0 to 1.
 +
Second you need to do it slowly enough so that the human eye can see the blink.
 +
There are a lot of ways to do this. I am going to take what I think is the simplest to understand. This method uses a few functions that are documented in the BoostC compiler manual. ( Read it to get an idea of what you can do, also read the section on programming in C. You will not understand it all the first, second, or third time through, but each time you will understand more, and at least be able to look things up more quickly. )
  
* One you need to change the value of a port back and froth from 0 to 1.
+
set_bit( ) is used to set one bit of a variable or port to 1.
* Second you need to do it slowly enough so that the human eye can see the blink.
+
clear_bit( ) is used to set one bit of a variable or port to 0.
 +
delay_ms() is used to just delay the program by a number of milli seconds ( thousands of a second ).
  
There are a lot of ways to do this. I am going to take what I think is the simplest to understand. This method uses a few functions that are documented in the BoostC compiler manual. ( Read it to get an idea of what you can do, also read the section on programming in C. You will not understand it all the first, second, or third time through, but each time you will understand more, and at least be able to look things up more quickly. )
+
We can put this together like this:
 +
 
 +
while( 1 ) {
 +
 
 +
set_bit( portb, 0 ); // connect the led to port B,
 +
// bit 0 this is RB0 or pin33
 +
// the led will turn on
 +
delay_ms( 250 ); // just wait for ¼ of a second
 +
 
 +
clear_bit( portb, 0 ); // the led will turn off
  
* set_bit( ) is used to set one bit of a variable or port to 1.
+
delay_ms( 250 ); // just wait for ¼ of a second
* clear_bit( ) is used to set one bit of a variable or port to 0.
 
* delay_ms() is used to just delay the program by a number of milli seconds ( thousands of a second ).
 
  
We can put this together like this:
 
  
  '''while( 1 ) {'''
+
}
 
 
      '''set_bit( portb, 0 ); // connect the led to port B,'''
 
      '''// bit 0 this is RB0 or pin33'''
 
      '''// the led will turn on'''
 
      '''delay_ms( 250 ); // just wait for ¼ of a second'''
 
 
 
      '''clear_bit( portb, 0 ); // the led will turn off'''
 
 
 
      '''delay_ms( 250 ); // just wait for ¼ of a second'''
 
 
 
 
 
  '''}'''
 
  
 
The led should cycle through on, then off, all in one half of a second.
 
The led should cycle through on, then off, all in one half of a second.
Line 270: Line 262:
 
Check your program by building it ( on the menu Build -> Build ). A successful build does not mean that the program works, only that it is a program that the compiler can understand. To really test it you need to assemble the hardware, program the chip, and try it out. A short cut that can help is to simulate the program.
 
Check your program by building it ( on the menu Build -> Build ). A successful build does not mean that the program works, only that it is a program that the compiler can understand. To really test it you need to assemble the hardware, program the chip, and try it out. A short cut that can help is to simulate the program.
  
=== Using the simulator to check the program ===
+
Using the simulator to check the program
  
 
The simulator ( also known as the debugger ) lets the PC run the program as if it were a PIC. You can also look at values of variables, registers, and ports as the program runs. This is really useful in determining if the program is working correctly, understanding how PICs run, and fixing mistakes in the program.
 
The simulator ( also known as the debugger ) lets the PC run the program as if it were a PIC. You can also look at values of variables, registers, and ports as the program runs. This is really useful in determining if the program is working correctly, understanding how PICs run, and fixing mistakes in the program.
Line 277: Line 269:
 
Press Debug Icon, A bug, usually next to last icon on the icon bar.  
 
Press Debug Icon, A bug, usually next to last icon on the icon bar.  
 
Debugging.... should show in lower panel, a green bar should appear in the edition across  
 
Debugging.... should show in lower panel, a green bar should appear in the edition across  
 
+
trisa = 0x00;
  '''trisa = 0x00;'''
 
 
 
 
the first line of the main program. The program has started running and then has stopped on this line in the program.
 
the first line of the main program. The program has started running and then has stopped on this line in the program.
 
Press the “step over” icon, ( one line down from debug icon, first on row, “hover” will show “step over” ).  
 
Press the “step over” icon, ( one line down from debug icon, first on row, “hover” will show “step over” ).  
The green line will advance by one, the debugger has just executed the prior line of code and stopped again. Use the menu: View -> Watch Bar A Panel will open on the right, it is called the Watch Panel, at the top it say “Watch”.
+
The green line will advance by one, the debugger has just executed the prior line of code and stopped again.
 +
Use the menu: View -> Watch Bar A Panel will open on the right, it is called the Watch Panel, at the top it say “Watch”.
 
Right click in the Watch Panel a popup menu will appear, select add, in the dialog box type “portb” and click <ok>. portb will appear in the watch panel. Put the mouse on portb in the watch panel and right click, in the popup menu select binary. This will change the display of portb to binary. This is good so you can see each bit of the port ( although 0 bits left will not be displayed ) We are going to look in particular at bit 3 ( oddly this is the fourth bit from the left, the first bit is bit 0, not bit one.
 
Right click in the Watch Panel a popup menu will appear, select add, in the dialog box type “portb” and click <ok>. portb will appear in the watch panel. Put the mouse on portb in the watch panel and right click, in the popup menu select binary. This will change the display of portb to binary. This is good so you can see each bit of the port ( although 0 bits left will not be displayed ) We are going to look in particular at bit 3 ( oddly this is the fourth bit from the left, the first bit is bit 0, not bit one.
 
Use the step over icon until the program gets down to the line portc = 0x00; by this time the watch window should show portb as 0.
 
Use the step over icon until the program gets down to the line portc = 0x00; by this time the watch window should show portb as 0.
Line 295: Line 286:
  
  
=== Running the program for Real ===
+
Running the program for Real
  
 
To really run the program you will need to complete 2 additional steps, build the circuit, program the chip and finally power it up.
 
To really run the program you will need to complete 2 additional steps, build the circuit, program the chip and finally power it up.
Line 303: Line 294:
 
I recommend that you build the circuit on a poto or breadboard. The board has many connections prewired and allows many components and wires to simply be pushed in holes in the board to make the connections. Here is a picture:
 
I recommend that you build the circuit on a poto or breadboard. The board has many connections prewired and allows many components and wires to simply be pushed in holes in the board to make the connections. Here is a picture:
  
    still need to upload the picture
+
 
  
 
I normally use the connections marked in red ( all connected together on the top, all connected together on the bottom, but top and bottom not connected together ) as +5 volts and the blue as 0 volts or ground. Use jumper wires to connect the red top line to the red bottom line, and similarly for the blue.
 
I normally use the connections marked in red ( all connected together on the top, all connected together on the bottom, but top and bottom not connected together ) as +5 volts and the blue as 0 volts or ground. Use jumper wires to connect the red top line to the red bottom line, and similarly for the blue.
Line 326: Line 317:
 
Here is the resulting circuit for me ( with unused pins not connected, but configured as outputs in the code )
 
Here is the resulting circuit for me ( with unused pins not connected, but configured as outputs in the code )
  
    still need the picture
+
 
 +
 
 +
 
  
 
== Programming the Chip  ==
 
== Programming the Chip  ==
Line 403: Line 396:
 
BoostC has a bunch of built in subroutines for lots of things including dealing with peripherals. Read the manual to see what they are.
 
BoostC has a bunch of built in subroutines for lots of things including dealing with peripherals. Read the manual to see what they are.
  
== Appendix: Error Messages and Some Gotchas ==
+
Appendix: Error Messages and Some Gotchas
  
  
Line 414: Line 407:
 
Error messages are one of the weaknesses of the compiler. I have also not been able to find a comprehensive listing of the messages and their meanings.
 
Error messages are one of the weaknesses of the compiler. I have also not been able to find a comprehensive listing of the messages and their meanings.
  
If you do get an error you do not understand, get the exact wording and use Google advanced search to search the SourceBoost forum website at: [http://forum.sourceboost.com/ | Source Boost Forum ]
+
If you do get an error you do not understand, get the exact wording and use Google advanced search to search the SourceBoost forum website at: http://forum.sourceboost.com/
 +
 
  
 
Some errors that have cost me a good bit of time
 
Some errors that have cost me a good bit of time
  
 +
Cause
 +
Error message
 +
Comment
 +
If ( ... ) instead of if( ... )
  
{| class="wikitable"
+
Capitalization matters.
|-valign="top"
+
Forgetting to put the semicolon at the end of a line.
|Cause
+
Missing semicolon
|Error message
+
Normally it is just missing at the end of the line listed by the error message, but not always.
|Comment
+
 
 +
 
 +
 
 +
set-bit instead of set_bit
 +
failure
 +
C:\Russ\PER\_XX\PIC\BoostC\MyTutorial\HelloWorld.c(100): error: missing semicolon
 +
C:\Russ\PER\_XX\PIC\BoostC\MyTutorial\HelloWorld.c(100): error: missing right paren
 +
C:\Russ\PER\_XX\PIC\BoostC\MyTutorial\HelloWorld.c(37): error: failure
 +
 
 +
 
 +
Set-bit is subtraction not the name of a subroutine or function. Note that the error message is “wrong”. I think I have gotten other error messages for the same error. You might want to do a search on set-bit and clear-bit to make sure you have not used them.
 +
 
 +
 
 +
 
 +
“Equal sign” instead of “is equal sign”:  = instead of ==
 +
 
 +
Normally none!
 +
Inside an if statement as in if( a = b ) then equal sign is almost always wrong, if you are testing for equality you want if ( a == b ).
 +
 
 +
 
 +
 
 +
Low voltage programming on
 +
None, but port b 3 does not work.
 +
Turn off LVP ( low voltage programming ) to use this port.
 +
 
 +
 
 +
 
 +
Analog input enabled
 +
None but port a I/O will not work.
 +
Simulator may catch this error.
  
  
|-valign="top"
 
|If ( ... ) instead of if( ... )
 
|
 
|Capitalization matters.
 
<!-------------------------------->
 
|-valign="top"
 
|Forgetting to put the semicolon at the end of a line.
 
|Missing semicolon
 
|Normally it is just missing at the end of the line listed by the error message, but not always.  Sometimes you get this message when a missing semicolon is not the problem.  Just to fake you out.
 
<!-------------------------------->
 
|-valign="top"
 
|set-bit instead of set_bit
 
|failure
 
HelloWorld.c(100): error: missing semicolon
 
HelloWorld.c(100): error: missing right paren
 
HelloWorld.c(37): error: failure
 
|Set-bit is subtraction not the name of a subroutine or function. Note that the error message is “wrong”. I think I have gotten other error messages for the same error. You might want to do a search on set-bit and clear-bit to make sure you have not used them.
 
<!-------------------------------->
 
|-valign="top"
 
|“Equal sign” instead of “is equal sign”:  = instead of ==
 
|Normally none! no error message.
 
|Inside an if statement as in if( a = b ) then equal sign is almost always wrong, if you are testing for equality you want if ( a == b ).
 
<!-------------------------------->
 
|-valign="top"
 
|Low voltage programming on
 
|None, but port b 3 does not work.
 
|Turn off LVP ( low voltage programming ) to use this port.
 
<!-------------------------------->
 
|-valign="top"
 
|Analog input enabled
 
|None but porta I/O will not work.
 
|Simulator may catch this error.
 
<!--------------------------------
 
|-valign="top"
 
|
 
|
 
|
 
<!--------------------------------
 
|-valign="top"
 
|
 
|
 
|
 
<!--------------------------------
 
|-valign="top"
 
|
 
|
 
|
 
<!--------------------------------
 
|-valign="top"
 
|
 
|
 
|
 
<!--------------------------------
 
|-valign="top"
 
|
 
|
 
|
 
<!-------------------------------->
 
  
|}
 
  
 
== Appendix: Other Documents You Should Reference ==
 
== Appendix: Other Documents You Should Reference ==
Line 497: Line 465:
 
PIC16F87XA Datasheet:
 
PIC16F87XA Datasheet:
 
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1335&dDocName=en010242 under datasheets at the right hand panel on the page
 
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1335&dDocName=en010242 under datasheets at the right hand panel on the page
 +
  
 
BoostC Compiler Help:  
 
BoostC Compiler Help:  
Line 502: Line 471:
  
  
Lots of PIC Links use page search on PICIntro, and/or Tutorial, and/or Info for more or less instructional materials.
+
Lots of PIC Links ( mostly beginner level ) at
* [[PIC Links]]
 
* [[Use C for PIC Programming!]]
 
* [[BoostC tiny Wiki]]
 
* [[BitWacker PIC and Other Microcontroller to Java Communications]]
 
* [[A Tutorial on PIC interrupts using BoostC including Example Programs]]
 
* [[PIC Programmers, In Circuit Programming and BootLoaders]]
 
  
 +
http://home.comcast.net/~russ_hensel/RClub/ProjectLinks.html
 +
 +
once in this document search on the word: PIC to find only introductions to the PIC search on the word: PICIntro
  
 
More help with C on the web:
 
More help with C on the web:
Line 520: Line 486:
 
Programming in C: A Tutorial - Brian W. Kernighan - Bell Laboratories, Murray Hill, N. J. http://www.lysator.liu.se/c/bwk-tutor.html
 
Programming in C: A Tutorial - Brian W. Kernighan - Bell Laboratories, Murray Hill, N. J. http://www.lysator.liu.se/c/bwk-tutor.html
  
* [[Microcontroller]]
+
 
  
 
== Appendix: What you Need for this Project  ==
 
== Appendix: What you Need for this Project  ==
Line 561: Line 527:
 
CF1 This capacitor helps smooth out ripple and noise in the output. 50 micro F should do.
 
CF1 This capacitor helps smooth out ripple and noise in the output. 50 micro F should do.
 
CF2 This capacitor helps smooth out high frequency in the output. Normally capacitors like this are placed close to the power pins of each integrated circuit. A ceramic capacitor of .1 or .01 micro F should serve.
 
CF2 This capacitor helps smooth out high frequency in the output. Normally capacitors like this are placed close to the power pins of each integrated circuit. A ceramic capacitor of .1 or .01 micro F should serve.
 
 
[[category:Microcontroller]][[category:PIC]]
 

Please note that all contributions to OpenCircuits may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see OpenCircuits:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)