Editing Serial Communications (RS232) in 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 13: Line 13:
 
=== News  ===
 
=== News  ===
  
*This page is still draft, but near final, will work on it if you have questions or I am otherwise motivated.
+
This page is still draft
*My most recent version seems to have a new problem with the 877, working on it.  Supporting multiple chips seems to have caused me to introduce a bug.  New version should come out in the next few days, basi code struchture however will not change.
 
  
 
=== Features  ===
 
=== Features  ===
Line 32: Line 31:
 
<!-------------------------------->
 
<!-------------------------------->
 
|-valign="top"
 
|-valign="top"
|Code includes preprocessing for changing the processor and ( coming soon baud rate )
+
|Code includes preprocessing for changing the processor or baud rate
 
|uses multiple files and #define
 
|uses multiple files and #define
<!-------------------------------->
 
|-valign="top"
 
|Tested on 16F877A and 18F2550
 
|should be very easy to use ( almost no changes ) on related processors
 
 
<!-------------------------------->
 
<!-------------------------------->
 
|-valign="top"
 
|-valign="top"
Line 115: Line 110:
  
  
[[Stepper Motor Tester]] has a Eagle file that will work for this demo.  You can drop the stepper driver chip.  Even the level shifter can be dropped if you use a cable with a level shifter.  The circuit is an easy project to do on a proto board.  Another project, with very similiar hardware, but no level shifter is [[PIC based Stepper Motor Dancing Analog Clock]]
+
[[Stepper Motor Tester]] has a Eagle file that will work for this demo.  You can drop the stepper driver chip.  Even the level shifter can be dropped if you use a cable with a level shifter.  The circuit is an easy project to do on a proto board.  Another project, with very similiar hardware, but no loevel shifter is [[PIC based Stepper Motor Dancing Analog Clock]]
  
 
=== Compiling the Program ===
 
=== Compiling the Program ===
Line 121: Line 116:
 
The code for the library and the demo program is in one zip file ( called DemoSerial.zip, see Download below ). Unzip into a directory of its own.  Open the project file SerialDemo.__c and compile with the source boost C compiler.  The source files are SerialDemo.c SerialDemo.h.....
 
The code for the library and the demo program is in one zip file ( called DemoSerial.zip, see Download below ). Unzip into a directory of its own.  Open the project file SerialDemo.__c and compile with the source boost C compiler.  The source files are SerialDemo.c SerialDemo.h.....
  
Before compiling make sure you change the target PIC to whatever you are using and check the #defines to see that they are right for your code  Project.h has some of the most importantSee File Structure and Pre Processing below.
+
I am not sure if the program is small enough to compile with the free compiler, my compiler reports a size of 2392 bytes of ROM, which is probably not small enoughThere should enough demo code that can be deleted to get under the 2K limit.
  
I also use a non standard location for my compiler and you may need to adjust for your setup.  Check Options -> Tools -> and make sure the setting there corresponds to you set up.
+
Before compiling make sure you change the target PIC to whatever you are using and check the #defines to see that they are right for your code Project.h has some of the most important.
 
 
You should do a full build, what is called a clean and build in some environments.  You can erase the intermediary files befor you build or press the control key at the same time you click the build icon.
 
 
   
 
   
Before you actually try it with real hardware review your clock frequency and baud rate settings etc. .... in the code.
+
Before you actually try it with real hardware review your clock frequency and baud rate settings in the code.
 
 
I am not sure if the program is small enough to compile with the free compiler, my compiler reports a size of 2392 bytes of ROM, which is probably not small enough.  There should enough demo code that can be deleted to get under the 2K limit.
 
 
 
 
 
==== File Structure and Pre Processing ====
 
 
 
I am working on a standard sturcture for my programs to make them adapatable to different configurations including processor, clock speed etc.  For you to make sense of this you need to understand a bit about the C preprocessor esp. #include and #define.  Note that I use #warning for messages about compile options, they are not warnings and normall begin with "Info >>".
 
 
 
===== mainfile.c =====
 
 
 
Note this is not necessiarly named mainfile, for this demo the mainfile is DemoSerial.c.  This is whrere the main part of the program resides.  I almost always have a .h file for each mainfile, because that seems to be how the pros do it.  Not entirely sure why.  I do included a lot of preprocess and #define stuff in the mainfile.  Definitions for the port configuration etc. are currently in mainfile.c.
 
 
 
===== Project.h =====
 
 
 
All my code has an include for project.h  this file is for specifing the main configuration options.  Commonly some of these options are collected together in setups which are numbered.  Setups with numbers below 100 should not be changed in your project, if one of the low numbered setups is not adaquate you can add a new one with a number above 100.  Currently all my projects are defined for a baud rate of 19.2 K.  In the future the baud rate may be set in project.h.  For now you would have to mess with SerialLib.h.
 
 
 
For details on what each #define means see comments in the file.
 
 
 
===== Fuse.h =====
 
 
 
Contains the fuse settings.  These are determined from the stuff set up in Project.h.  Fuse.h should be included only once, this should be in the mainfile right after the include for Project.h.  Fuse.h should not be modified for an individual project, you should be able to make additions so it will work with all projects.
 
 
 
===== Library Files =====
 
 
 
My libraries are not precompiled, they are just .c and .h files that you make a copy of for your project and compile with it.  Thus when the files are updated they will not effect your project until you copy in new versions.  This leaves you in control of adapting to the changes.  The library here is SerialLib.c ( and its .h file ).  Add the .c files and .h files to your project, #include the .h files to any other file using the library.
 
  
 
=== Running the Program ===
 
=== Running the Program ===
Line 242: Line 210:
 
=== Download ===
 
=== Download ===
  
Zip file here [http://home.comcast.net/~russ_hensel/OC/DemoSerial_v5.zip DemoSerial_v5.zip] I may have more recent versions, email me if you want to check [[russ_hensel]]
+
Zip file here ...comming....  I may have more recent versions, email me if you want to check [[russ_hensel]]
  
 
=== Projects using this Library ===
 
=== Projects using this Library ===

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)