Difference between revisions of "Serial Communications Library -- BoostC and 16F877A"
Russ hensel (talk | contribs) |
Russ hensel (talk | contribs) |
||
Line 123: | Line 123: | ||
|Command | |Command | ||
|Details | |Details | ||
− | |||
− | |||
− | |||
− | |||
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
Line 144: | Line 140: | ||
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
− | | | + | |h |
− | + | |Print out a series of numbers using print_hex. | |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
− | | | + | |b |
− | | | + | |Print out a series of numbers using print_bin. |
+ | |||
+ | |||
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
− | | | + | |e |
− | + | |Echo a series of keystrokes as hex values. | |
− | | | ||
<!-------------------------------- | <!-------------------------------- |
Revision as of 07:30, 24 September 2008
Contents
Summary
- Name: Serial Communications Library -- BoostC and 16F877A
- Purpose: A C library ( in source code form ) for serial communications together with a program demonstrating its use.
- Status: This page in draft. Code works but still in refinement, code available, email russ_hensel
- Technology: BoostC and PIC 16F877A
- Author: russ_hensel ( where you can find an email address to reach me )
- License: not fully determined, but open source and object code.
This is one of a series of articles on Microcontroller Serial Communications, rooted at this site here: Microcontroller Serial Communications Articles
Features
Feature | Details
|
Code is for USART hardware on PIC 16F877A. | Should be fairly easy to port to similiar processors |
Receive is interrupt driven. | Receive should be active all the time although overrunning the buffer is possible. |
Microcontroller Serial Communications Articles | |
Transmit is blocking. | During a transmit no activities that are not interrupt driven occur. |
Command interface is included. | PIC is setup to receive serial commands and respond to them. |
Command interface includes a stop command to halt long running operations. | Character is !
|
Input routines for parsing and converting a numerical parameter. | This makes commands like r22 able to pass the argument ( converted to binary ) to a subroutine. |
Option to make single letter commands case insensitive.
|
|
Realizes a protocal similar to the one found in the link on the right. | MC_RS232_Comm |
Beware of negative numbers which may not be handled as you expect. | |
Hardware for the Program
Compiling the Program
The code for the library and the demo program is in one zip file ( called .... ). Unzip into a directory of its own. Open the project file SerialDemo.__c and compile with the source boost compiler. The source files are SerialDemo.c SerialDemo.h.....
Running the Program
Running the DemoSerial demo program ( demo is set up to be caps insensitive, if you comment out this feature use lower case commands )
Once running the demo program supports the following commands. Use a terminal emulator set for..... One I like is ....... For full details on what each command does review the code, I have tried to fully comment the code so that it should be fairly easy to read. I have generally avoided coding tricks.
Command | Details |
r | Report the version of the software ( and possibly other infomation ). |
! | Stop whatever software is doing, give stopped message. |
d | Print out a series of numbers using serial_print_dec
(The library has different version of serial_print_dec for different argument types ) |
h | Print out a series of numbers using print_hex.
|
b | Print out a series of numbers using print_bin.
|
e | Echo a series of keystrokes as hex values.
|
Using the Library in Your Own Program
Code History
Origninal source code found, I think, on code on the SourceBoost website ( see program header for more inforation ). I have used the code on a series of different projects, it has evolvled with each one. I have added the code for a command interface, this is based on the idea that if you have serial capability then you may want to control it thru its serial connection.