/* 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 10:52, local time: 2024/11/8 19:36,
52.15.196.4:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©2024 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? <A HREF="http://sxlist.com/techref/microchip/mplab/sti-rs232/gps_sti_c.htm"> Colorized Source Code</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
The Backwoods Guide to Computer Lingo |
.