Define CLOCK_FREQUENCY = 16 Define CONFIG1 = 0x0f84 Define CONFIG2 = 0x1def OSCCON = 0x3c 'intosc=16mhz UsbSetVendorId 0x1235 UsbSetProductId 0x1234 UsbSetVersionNumber 0x1122 UsbSetManufacturerString "21century.com" UsbSetProductString "USB HID Device" UsbSetSerialNumberString "1111111111" UsbOnIoInGosub input_report_before_sending UsbOnIoOutGosub output_report_received UsbOnFtInGosub feature_report_before_sending UsbOnFtOutGosub feature_report_received AllDigital TRISC = %00111000 'SETS THE PORT STATUS 'TRISA = %11100000 'PDN OUT,RC3 PDN POWER DOWN PULLING LOW PUTS RECEIVER IN SLEEP MODE 'RSSI IN, RC4 PROPORTIONAL TO SIGNAL STRENGTH 'DATA IN, RC5 DIGITAL DATA FROM RECEIVER 'AUDIO IN,RA4 'AREF IN,RA5 Dim an3 As Byte Dim an2 As Byte Dim i As Byte Dim x(8) As Byte PORTC.3 = 1 PORTC.2 = 1 For i = 1 To 5 Toggle PORTC.1 'toggle LED for testing WaitMs 50 Toggle PORTC.1 WaitMs 50 Next i PORTC = 0xff UsbStart 'I hear the USB preamble here PORTC = 0 i = 0 loop: 'This program needs to wait for some bytes to be received through the serial port. 'The PIC16F1459 will respond to a PC call to send the PC data through the USB port. 'UsbStart 'Define SERIN_TIMEOUT_REG = INTCON 'I do not understand these two 'Define SERIN_TIMEOUT_BIT = T0IF 'set up PIC chip to receive data through serial port 'Wait for receive register to get a byte from serial port (portc.5) 'INTCON.GIE = 1 SPBRGH = %00110100 'my divisor for 600 baud SPBRGL = %00010100 PIE1.RCIE = 1 'enables the USART receive interrupt TXSTA.SYNC = 0 'SYNC(4)=0 TXSTA.BRGH = 1 BAUDCON.BRG16 = 1 RCSTA.SPEN = 1 'SPEN(7) = 1 RCSTA.CREN = 1 'CREN(4) = 1 If PIR1.RCIF = 1 Then x(i) = RCREG WaitMs 10 i = i + 1 If i = 5 Then i = 0 Endif x(3) = x(3) + 1 UsbService Toggle PORTC.3 'Test to see of loop is active WaitMs 22 Toggle PORTC.3 WaitMs 22 Goto loop End feature_report_received: Toggle PORTC.2 an2 = an2 + 2 Return feature_report_before_sending: UsbFtBuffer(0) = x(0) 'UsbFtBuffer(0) - 1 UsbFtBuffer(1) = x(1) 'usbftbuffer(1) - 1 UsbFtBuffer(2) = x(2) 'UsbFtBuffer(2) - 1 UsbFtBuffer(3) = x(3) 'usbftbuffer(3) - 1 UsbFtBuffer(4) = x(4) 'usbftbuffer(4) - 1 UsbFtBuffer(5) = i 'I can see how many data points were sent UsbFtBuffer(6) = an2 UsbFtBuffer(7) = an3 Return output_report_received: 'Toggle PORTC.3 'WaitMs 200 Return input_report_before_sending: UsbIoBuffer(0) = 3 'usbiobuffer(0) + 1 UsbIoBuffer(1) = 1 'usbiobuffer(1) + 1 UsbIoBuffer(2) = 4 'usbiobuffer(2) + 1 UsbIoBuffer(3) = 1 'UsbIoBuffer(3) + 1 UsbIoBuffer(4) = 5 'usbiobuffer(4) + 1 UsbIoBuffer(5) = 9 'usbiobuffer(5) + 1 UsbIoBuffer(6) = 1 'usbiobuffer(6) + 1 UsbIoBuffer(7) = 5 'usbiobuffer(7) + 1 Return