please dont rip this site

Microchip Mplab STI-RS232 Gps_sti

/ *
	Program gps_sti.c

	This program has been written to allow the quick creation of the sti files required by MPLAB
	for the testing of serial code written for the PIC 16F84, or other PICs using inverted TTL RS232
	input.  Visit for details the PIC 16F84 STV5730A On Screen 
	Display project board with serial interface.

	The program is run using the batch file gps_sti.bat with the command line as follows:
	gps_sti out_file.sti nnnnn  TEXT_LINE
	out_file.sti = the name of the sti file to be created.  Existing files are overwritten without warning.
	nnnnn = the number of cycles into the program you want the serial input to start
	TEXT_LINE  = the string of  ASCII characters you want converted into the sti file.
	gps_sti gpgga.sti 338399 $GPGGA,170834,4124.8963,N,08151.6838,W,1,05,1.5,280.2,M,-34.0,M,,*75

	Copyright © 2000 by The BlackBoxCameraTM Company Limited. All rights reserved.
	This code may be duplicated in whole or in part provided that [1] there
	is no commercial gain involved in the duplication, and [2] that this
	copyright notice is preserved on all copies.  

	Any enquiries or bug reports should be sent to


#include <stdio.h>
#include <time.h>

//Defines specific to PIC serial calculation
#define CLOCK_SPEED	9830400
//#define CLOCK_SPEED	4915200
#define BAUD2400	2400
#define BAUD4800	4800
#define BAUD9600	9600

void openOutputFile( char *lpszFilename );
void serialBits(char serialChar);
void makeStiFile( char *lpszStartCycle, char *lpszGPSString);

struct char_bitfield
	unsigned char bit0 : 1;
	unsigned char bit1 : 1;
	unsigned char bit2 : 1;
	unsigned char bit3 : 1;
	unsigned char bit4 : 1;
	unsigned char bit5 : 1;
	unsigned char bit6 : 1;
	unsigned char bit7 : 1;

FILE *out_file;
long counter;

void main(int argc, char *argv[])
	openOutputFile( argv[1] );

	makeStiFile( argv[2], argv[3] );


void makeStiFile( char *lpszStartCycle, char *lpszGPSString)
	int i;

	fprintf(out_file,"CYCLE\tRB0\t;%s\n", lpszGPSString );	//Write first line of the .sti file

	i = 0;

	counter = 0;
	fprintf(out_file,"%d\t0\n", counter);	// Initial setting
	counter = atol( lpszStartCycle );

	while( lpszGPSString[i]  != '\0' )
		if( lpszGPSString[i]  == '_' )
			lpszGPSString[i] = ' ' ;

		serialBits( lpszGPSString[i] );



	serialBits( 0x0D );	//Carriage return
	serialBits( 0x0A );	//Linefeed


void serialBits(char serialChar)
	int j;
	struct char_bitfield *character;

	character =  (struct char_bitfield *) &serialChar;
	fprintf(out_file,"%d\t1\t;Start bit edge  %c\n", counter, serialChar );

	for(j = 0; j< 8; j++)
		counter += INTERVAL;

			fprintf(out_file,"%d\t0\n", counter);
			fprintf(out_file,"%d\t1\n", counter);

		serialChar = serialChar>>1;


	counter += INTERVAL;							// Stop bit of 1.5 bit time
	fprintf(out_file,"%d\t0\t;Stop bit\n", counter);
	counter += INTERVAL / 2;
	fprintf(out_file,"%d\t0\n", counter);


void openOutputFile( char *lpszFilename )

	out_file = fopen(lpszFilename,"w"); /*open output file */
	if(out_file == NULL)
		perror("open failed * on output file");


file: /Techref/microchip/mplab/sti-rs232/gps_sti.c, 3KB, , updated: 2000/12/7 18:59, local time: 2018/2/24 10:14,

 ©2018 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE! / 

<A HREF=""> microchip mplab sti-rs232 gps_sti</A>

Did you find what you needed?

Quick, and RELIABLE! RCL-1 RS232 Level Converter in a DB9 backshell only $25.00
Ashley Roll has put together a really nice little unit here. Leave off the MAX232 and keep these handy for the few times you need true RS232!

Welcome to!