__config 3f79 ; Program RecPIC ; ; This program uses the Analogue to Digital Convertor to generate ; 8000, 8 bit samples per second. It sends these via a 115,200bps ; serial port link to a PC. The companion program "RecPIC.exe" will ; convert these samples to a ".au" file. This file can then be played ; via Windows Media Player. ; ; The PIC used is a 16F73. ; Loop length for 8000 samples/sec (125uS) and 20MHz Xtal ; (0.2uS per instruction) is 625 Instructions ; ;Internal File Assignments STATUS EQU 0x03 ;Used for Zero bit PORTA EQU 0x05 PORTB EQU 0x06 PORTC EQU 0x07 TXSTA EQU 0x18 SPBRG EQU 0x19 RCSTA EQU 0x18 TXREG EQU 0x19 ADRES EQU 0x1E ADCON EQU 0x1F ;Internal Bit Assignments W EQU 0 F EQU 1 GO EQU 2 ZERO EQU 2 ;User File Assignments TIMER1 EQU 0x21 COUNT EQU 0x22 TEMP EQU 0x23 ;User Bit Assignments GREEN EQU 2 RED EQU 3 ;Program Starts Here!!!!!!!!! ORG 0x10 ;Initialise Registers BSF 3, 5 BCF 3, 6 MOVLW 0xC0 MOVWF PORTC ;PORTC = Output except UART CLRF PORTB ;PORTB = Output MOVLW 0xFF MOVWF PORTA ;PORTA = Input MOVLW 0x0A MOVWF SPBRG ;Set Baud Rate to 115200 BSF TXSTA, 2 ;Set Baud Rate to High BCF TXSTA, 4 ;Set Async operation BCF 3, 5 BSF RCSTA, 7 BSF 3, 5 BSF TXSTA, 5 MOVLW 0x04 MOVWF ADCON BCF 3, 5 MOVLW 0x80 MOVWF ADCON BSF ADCON, 0 CLRF COUNT ;Time Loop (625 instructions total) LOOP MOVLW 0x10 MOVWF TIMER1 T0 DECFSZ TIMER1, F GOTO T0 BSF ADCON, GO NOP ;Trimmer NOPs NOP NOP NOP NOP NOP NOP NOP MOVLW 0x0C MOVWF PORTC MOVLW 0xBB ;BC+10=CC = 201*3 = 603+22=625 MOVWF TIMER1 T1 DECFSZ TIMER1, F GOTO T1 MOVF ADRES, W MOVWF TXREG IORLW 0x0F ADDLW 0x01 BTFSC STATUS, ZERO BCF PORTC, RED ADDLW 0x10 BTFSC STATUS, ZERO BCF PORTC, GREEN GOTO LOOP END