please dont rip this site
/*
	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 http://www.STV5730A.co.uk 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
	where:
	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.
	eg:
	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 sales@blackboxcamera.com

*/




#include <stdio.h>
#include <time.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>

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

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] );

	fclose(out_file);
}


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] );

		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;

		if(character->bit0)
		{
			fprintf(out_file,"%d\t0\n", counter);
		}
		else
		{
			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");
		exit(1);
	}

}


file: /Techref/microchip/mplab/sti-rs232/gps_sti_c.htm, 15KB, , updated: 2005/1/17 11:52, local time: 2022/9/25 07:49,
TOP NEW HELP FIND: 
44.201.95.84:LOG IN

 ©2022 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="http://piclist.com/techref/microchip/mplab/sti-rs232/gps_sti_c.htm"> Colorized Source Code</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2022 contributors:
o List host: MIT, Site host massmind.org, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
 

Welcome to piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .