> I noticed Peter Moreton mentioned having a Lassen SQ connected to a > PIC18F452. > Peter if you're still on the list: Can you tell me what you did to = get=20 > them > talking? > Thanks, > -matt redmond Matt, I spent some time looking thru my backups tonight, but cannot find a schematic for the PIC / Lassen SQ circuit I described. I reworked the = design for an Atmel ATmega128, and seemingly through away the PIC version of = the schematic. However, there is some C18 source code from this project = which I include below, which *might* be useful. From the code, I can see that I actually used the USART to talk to the Lassen SQ. If this code is = useful, I can bundle up all the source including headers and email it directly to = you. Peter Moreton /* * R700 Vehicle Telemetry Recorder * Author : Peter Moreton=09 * Revision 1.0 11 June 2003 * * Design notes: * The PIC18F452 is clocked as 16Mhz, giving 4 MIPS instruction rate.=20 * RS232 Comms at 1200 to 76.8 Kbaud can be implemented at this clock=20 * rate with a baud rate accuracy of 0.16%. The 16Mhz clock is used * to generate the High Resolution Timebases needed for CCP etc. The * High Accuracy Timebase is generated from a 7.5ppm 32.768 khz xtal=20 * on Timer1, producing a clock which can be disciplined by GPS. *=20 */ #include #include #include #include #include #include #include "LEDMatrix.h" #define TRUE 1 #define FALSE 0 #define DLE 0x10 #define ETX 0x3 // Global variables used primarily to get data from interrupt service routines=20 static unsigned long julian =3D 0; // Setup Interrupt Service Routines for low & high priority interrupts void low_priority_isr (void); void high_priority_isr (void); #pragma code low_vector=3D0x18 void low_interrupt (void) { // Inline assembly that will jump to the low priority ISR. _asm GOTO low_priority_isr _endasm } #pragma code // Reset to the default code section. #pragma code high_vector=3D0x08 void high_interrupt (void) { // Inline assembly that will jump to the high priority ISR. _asm GOTO high_priority_isr _endasm } #pragma code // Reset to the default code section. #pragma interruptlow low_priority_isr save=3DPROD void low_priority_isr (void) { char GPSChar, GPSUTC[10]; int GPSStrPtr; static char GPSStr[128]; if (PIR1bits.RCIF=3D=3D1) // USART RX flag tripped? { // TSIP packet format is: DLE pkt-id data-bytes DLE ETX PIR1bits.RCIF=3D0; // Reset the flag GPSChar =3D ReadUSART(); // Get the character if (GPSChar =3D=3D ETX) // End of TSIP packet { GPSUTC[0]=3DGPSStr[7]; // Copy HHMMSS to HH:MM:SS GPSUTC[1]=3DGPSStr[8]; GPSUTC[2]=3D':'; GPSUTC[3]=3DGPSStr[9]; GPSUTC[4]=3DGPSStr[10]; GPSUTC[5]=3D':'; GPSUTC[6]=3DGPSStr[11]; GPSUTC[7]=3DGPSStr[12]; GPSUTC[8]=3D'\0';=09 PutSMatrix(GPSUTC, 0); } GPSStrPtr=3D0; } else { GPSStr[GPSStrPtr++] =3D GPSChar; if (GPSStrPtr =3D=3D 128) // About to write over end of buffer? GPSStrPtr =3D 0; //=20 } if ((PORTC & 0x8) =3D=3D 0) // Port RC4 =3D RS232 data RX PORTC|=3D0x8; =09 else PORTC&=3D0xF7; } } #pragma interrupt high_priority_isr save=3DPROD void high_priority_isr (void) { if (PIR1bits.TMR1IF=3D=3D1) // High-accuracy timebase, TIMER1 has overflowed { PIR1bits.TMR1IF=3D0; // Reset the TIMER1 overflow interrupt flag=20 TMR1H =3D 0x80; // Set Timer1 to 0x8000 + elapsed time // Compute UTC timebase julian++; } } // End of interrupt processing code=20 void main (void) { int count, i=3D0; unsigned long julianx=3D0; unsigned char opcode; =09 // '1' bit is input, '0' bit is output TRISA =3D 0b11111111; // Port A is presently unused. Set to all inputs TRISB =3D 0b11100000; // RB0,1,2 used by LED Matrix TRISC =3D 0b11000011; // RC0,1 used by 32khz osc, RC6,7 used by RS232 // Issue startup msg to LED matrix display // OpenMatrix(); PutBMatrix(MATRIX_LAMPTEST); Delay10KTCYx(0); PutBMatrix(MATRIX_CLEAR); PutBMatrix(MATRIX_BRIGHT_40); // 40% PutRSMatrix("TELEMETRY ", 0); Delay10KTCYx(0); PutRSMatrix("FW REV 1.1", 0); Delay10KTCYx(0); PutRSMatrix("INIT OK ", 0); Delay10KTCYx(0); // Enable the TMR1 interrupt, setting up the timer as an external 32.768 khz, 16-bit clock =20 OpenTimer1 (TIMER_INT_ON & T1_PS_1_1 & T1_OSC1EN_ON & T1_8BIT_RW); TMR1H =3D 0x80; // Set Timer1 to 0x8000 (=3D dec 32768) + elapsed time (1 second) RCONbits.IPEN =3D 1; // Enable prioritized interrupts IPR1bits.TMR1IP =3D 1; // Timer1 overflow is high priority IPR1bits.RCIP =3D 0; // USART receive is low priority INTCONbits.GIE =3D 1; // Enable global interrupts INTCONbits.PEIE =3D 1; // Enable peripheral interrupts // Open USART with SPBRG of 25 =3D 9600 baud @ 16Mhz xtal. Comms are 9600 baud, 8, odd, 1 OpenUSART( USART_TX_INT_OFF & USART_RX_INT_ON & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_LOW, 25); while (1) // Main routine; do this forever { if (julianx !=3D julian) // Time changed ? { julianx =3D julian; =09 if ((PORTC & 0x4) =3D=3D 0) // Port RC3 =3D 1PPS signal. Ultrabright LED beacon. PORTC|=3D0x4; =09 else PORTC&=3D0xFB; } } } -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.