; WRITTEN BY: TOM SCARFF ; DATE: 23/10/2001 ; ITERATION: 1.0 ; FILE SAVED AS: drm_vel3.ASM ; FOR: PIC16F877 ; CLOCK: 4.00 MHz CRYSTAL ; INSTRUCTION CLOCK: 1.00 MHz T= luS ; PROGRAMME FUNCTION: To read drum trigger i/p on ; A/D data in for ch0-7 i/ps ; and to transmit it to MIDI out. list p=16F877 ; tells the assembler which PIC #include "p16F877.inc" ; general register file __CONFIG _CP_ALL & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _XT_OSC & _WRT_ENABLE_OFF & _LVP_OFF & _DEBUG_OFF & _CPD_OFF ; '__CONFIG' directive is used to embed configuration data within .asm file. ; The lables following the directive are located in the respective .inc file. ; See respective data sheet for additional information on configuration word. #DEFINE PAGE0 BCF 3,5 #DEFINE PAGE1 BSF 3,5 lcd_data equ PORTC lcd_data_tris equ TRISC lcd_cntl equ PORTC ;************************************************************* ; Constant Assignments ;************************************************************* e equ 4 ; lcd enable control line r_w equ 1 ; lcd read/write control line rs equ 5 ; lcd register select control line CARRY EQU 0 ; CARRY BIT disp_on equ 0x0c clr_disp equ 0x01 entry_inc equ 0x06 dd_ram_addr equ 0x80 ; ;************************************************************** ; Variable Assignment Addresses ;************************************************************** ; ; temp1 equ 0x20 temp equ 0x21 char equ 0x22 msd equ 0x23 lsd equ 0x24 ; BCD0 equ 25h BCD1 equ 26h BCD2 equ 27h CHARACTER equ 28h midich equ 29h input1 equ 2Ah input2 equ 2Bh input3 equ 2Ch input4 equ 2Dh input5 equ 2Eh input6 equ 2Fh input7 equ 30h input8 equ 31h base_addr equ 32h temp_data equ 33h AD_DATA equ 34h dlyreg2 equ 35h dlyreg3 equ 36h ctrller equ 42h drum equ 43h vel1 equ 44h vel2 equ 45h value1 equ 46h count equ 47h max_cnt equ 48h input9 equ 49h ;threshold input10 equ 4Ah ;senitivity input11 equ 4Bh ;delay ; 7fh end of data area ;************************************ ; Initialize EEPROM ;************************************ org 2100h dw 0x09,0x41,0x42,0x43,0x44,0x45,0x46,0x47 dw 0x48,0x0B,0x14,0x05,0x00,0x00,0x00,0x00 ;************************************ ; PROGRAMME Reset Point ;************************************ org 00 ; reset vector goto init ;************************************ ; Switch Debounce Delay (variable) 1-255mS ;************************************ sw_dbnc movf input11,W ; Delay routine variable movwf dlyreg2 debnce call delay3 decfsz dlyreg2 goto debnce return ;************************************* ; Delay Subroutine (1 mS) ;************************************* delay3 movlw .165 movwf dlyreg3 dly3 decfsz dlyreg3 goto dly3 movlw .165 movwf dlyreg3 dly4 decfsz dlyreg3 goto dly4 nop return ;****************************************** ; transmission complete subroutine ;***************+************************** txchar bsf STATUS,RP0 btfss TXSTA,1 ; test for end of transmission goto $-1 bcf STATUS,RP0 return ;********************************************* ; Start A/D conversion Subroutine ;********************************************* convert bsf ADCON0,2 ;set GO/DONE Bit btfsc ADCON0,2 goto $-1 rrf ADRESH,W andlw 07Fh movwf AD_DATA return ;*********************************#*** ; Output MIDI note-on data ;************************************** noteon movf midich,W addlw 090h ; note-on ch. from midich ;;;;;movlw 099h ; Note-on Channel 10 movwf TXREG ; send chazacter from W call txchar movf drum,W movwf TXREG ; send character from W call txchar movf vel1,W movwf TXREG ; send character from W call txchar return ;*********************************#*** ; Output MIDI note-off data ;************************************** noteoff movf midich,W addlw 080h ; note-off ch. from midich ;;;;;;;movlw 089h ; Note-off Channel 10 movwf TXREG ; send chazacter from W call txchar movf drum,W movwf TXREG ; send character from W call txchar movf vel1,W movwf TXREG ; send character from W call txchar return ;*********************************#*** ; Set Sensitivity ;************************************** set_sens movf input10,W ; input10=sensitivity addwf AD_DATA,F btfsc STATUS,C goto set127 btfss AD_DATA,7 return ; with original value + sens. set127 movlw 07Fh ; 127 movwf AD_DATA return ;************************************* ; Drum detect loop ;************************************** drm_det call convert call convert movf input9,W ; is drum hit? >threshold=input9 subwf AD_DATA,W ; (f) - (W)--> (dest) btfss STATUS,C ; Skip if result +Ve. ie f>W return ; no ;********** Detect Peak value ****************** clrf vel1 ; Find first -ve going value peak0 call convert call convert call set_sens movf AD_DATA,W movwf vel2 subwf vel1,W ; (f) - (W)--> (dest) btfsc STATUS,C ; Skip if result -Ve. ie f vel1 movwf vel1 goto peak0 call set_sens cont_noteon call noteon call sw_dbnc call noteoff return ;************************************ ; EEPROM Read for 16F877 ; ENTRY: W=address ; RETURN: W=data ;************************************ ee_read bcf STATUS,RP0 bsf STATUS,RP1 ; bank 2 movwf EEADR bsf STATUS,RP0 bsf STATUS,RP1 ; bank 3 bcf EECON1,EEPGD bsf EECON1,RD r1 btfsc EECON1,RD ; Wait to finish read. goto r1 bcf STATUS,RP0 ; now bank 2 movf EEDATA,W andlw 07Fh ; prevent value >127 bcf STATUS,RP1 ; now bank 0 return ;************************************ ; EEPROM Write for 16F877 ; ENTRY: base_addr=address, temp_data=data ; RETURN: ------- ;************************************ ee_write bsf STATUS,RP1 bsf STATUS,RP0 ;writing to eeprom, bank 3 btfsc EECON1,WR; is write finished? goto $-1 bcf STATUS,RP1 bcf STATUS,RP0 ; bank 0 movf base_addr,W; start addr. EEPROM bsf STATUS,RP1 ; bank 2 movwf EEADR bcf STATUS,RP1 ; bank 0 movf temp_data,W andlw 07Fh bsf STATUS,RP1 ; bank 2 movwf EEDATA bsf STATUS,RP0 ;writing to eeprom, bank 3 bcf EECON1,EEPGD bsf EECON1,WREN movlw 55h movwf EECON2 movlw 0AAh movwf EECON2 bsf EECON1,WR test_wr btfsc EECON1,WR; is write finished? goto test_wr bcf EECON1,WREN ; disable eeprom write! bcf STATUS,RP0 bcf STATUS,RP1 ; now bank 0 return ;******************************************** ; Initalise LCD Display ;******************************************** display_init call delay call delay call delay movlw 0x33 call send_cmd movlw 0x32 call send_cmd movlw 0x28 ;2 line LCD call send_cmd movlw 0x0C ; Display on, cursor off call send_cmd movlw 0x02 call send_cmd movlw 0x01 call send_cmd return ;************************************************************* ; Delay of 15 mS with 1 MHz clock ;************************************************************* delay ;;;return movlw .30 ; movwf msd ; clrf lsd ; dly0 decfsz lsd, f ; delay time = msd * ((3 * 256) + 3) * tcy goto dly0 ; decfsz msd, f ; goto dly0 return ;******************************************************************* ;*sendchar - sends character to lcd * ;*this routine splits the character into the upper and lower * ;*nibbles and sends them to the lcd, upper nibble first. * ;******************************************************************* ; send_char movwf char ;character to be sent is in w swapf char, w andlw 0x0F ;get upper nibble movwf lcd_data ;send data to lcd bsf lcd_cntl, rs ;set lcd to data mode bsf lcd_cntl, e ;toggle e for lcd bcf lcd_cntl, e call delay movf char, w andlw 0x0F ;get lower nibble movwf lcd_data ;send data to lcd bsf lcd_cntl, rs ;set lcd to data mode bsf lcd_cntl, e ;toggle e for lcd bcf lcd_cntl, e call delay return ;******************************************************************* ;* send_cmd - sends command to lcd * ;* this routine splits the command into the upper and lower * ;* nibbles and sends them to the lcd, upper nibble first. * ;******************************************************************* send_cmd movwf char ; character to be sent is in w swapf char,w andlw 0x0F ; get upper nibble movwf lcd_data ; send data to lcd bsf lcd_cntl,e ; toggle e for lcd bcf lcd_cntl,e call delay movf char,w andlw 0x0F ; get lower nibble movwf lcd_data ; send data to lcd bsf lcd_cntl,e ; toggle e for lcd bcf lcd_cntl,e call delay return ;******************************************************************* ; Binary To BCD Conversion Routine ; This routine converts the 8 bit binary number in the W Register ; to a 3 digit BCD number, in locations BCD0, BCD1 and BCD2. ; Converts from 00 to 255. (00 to FF hex). Adds 30h to get ASCII. ;******************************************************************* BINBCD clrf BCD2 clrf BCD1 movwf BCD0 hundrd movlw .100 subwf BCD0,W btfss STATUS,CARRY goto gtenth movwf BCD0 incf BCD2 goto hundrd gtenth movlw .10 subwf BCD0,W BTFSS STATUS,CARRY goto over movwf BCD0 incf BCD1 goto gtenth over movlw 030h ;convert to ASCII addwf BCD0,F ;by adding 30h addwf BCD1,F addwf BCD2,F return ;**************************************************************** ; Display Number+1 as 2 Characters for MIDI Channels 1-16 ;**************************************************************** disp2char movf CHARACTER,W addlw .01 call BINBCD movf BCD1,W CALL send_char movf BCD0,W CALL send_char return ;**************************************************************** ; Display Number as 3 Characters from 000-121 ;**************************************************************** disp3char MOVf CHARACTER,W call BINBCD movf BCD2,W CALL send_char movf BCD1,W CALL send_char movf BCD0,W CALL send_char return ;**************************************************************** ; Increment MIDI Channel Value ;**************************************************************** inc_chan movlw 0Fh ; is value 16 xorwf midich,W btfsc STATUS,Z ; is value already 16 ? return ; Yes, so return incf midich,F MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf midich,W movwf CHARACTER call disp2char return ;**************************************************************** ; Deccrement MIDI Channel Value ;**************************************************************** dec_chan movlw 00h xorwf midich,W btfsc STATUS,Z ; is value already 0 ? return ; Yes, so return decf midich,F ; No, so decrement MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf midich,W movwf CHARACTER call disp2char return ;**************************************************************** ; Increment Drum Value ;**************************************************************** inc_val movlw .127 ; is value 127? max. controller value xorwf temp,W btfsc STATUS,Z ; is value already 16 ? return ; Yes, so return incf temp,F MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf temp,W movwf CHARACTER call disp3char return ;**************************************************************** ; Deccrement Drum Value ;**************************************************************** dec_val movlw 00h xorwf temp,W btfsc STATUS,Z ; is value already 0 ? return ; Yes, so return decf temp,F ; No, so decrement MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf temp,W movwf CHARACTER call disp3char return ;**************************************************************** ; Increment Delay Value ;**************************************************************** inc_del movlw .255 ; is value 255? max. value xorwf temp,W btfsc STATUS,Z ; is value already 16 ? return ; Yes, so return incf temp,F MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf temp,W movwf CHARACTER call disp3char return ;**************************************************************** ; Deccrement Delay Value ;**************************************************************** dec_del movlw 01h xorwf temp,W btfsc STATUS,Z ; is value already 1 ? return ; Yes, so return decf temp,F ; No, so decrement MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf temp,W movwf CHARACTER call disp3char return ;**************************************************************** ; Menus ;**************************************************************** menu0 MOVLW 0C0h ; SET LINE CALL send_cmd ; SET IT movlw .05 ; For address org 0500h movwf PCLATH call msg2 clrw movwf PCLATH MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf midich,W movwf CHARACTER ; Display initial/previous value call disp2char loop0 btfss PORTB,6 call inc_chan btfss PORTB,5 call dec_chan btfss PORTB,7 return goto loop0 ;------------------------------------------------------------- menu1 MOVLW 0C0h ; SET LINE CALL send_cmd ; SET IT movlw .05 ; For address org 0500h movwf PCLATH call msg3_1 clrw movwf PCLATH MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf input1,W movwf CHARACTER ; Display initial/previous value call disp3char loop1 movf input1,W movwf temp btfss PORTB,6 call inc_val btfss PORTB,5 call dec_val movf temp,W movwf input1 btfss PORTB,7 return goto loop1 ;----------------------------------------------------------------- menu2 MOVLW 0C0h ; SET LINE CALL send_cmd ; SET IT movlw .05 ; For address org 0500h movwf PCLATH call msg3_2 clrw movwf PCLATH MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf input2,W movwf CHARACTER ; Display initial/previous value call disp3char loop2 movf input2,W movwf temp btfss PORTB,6 call inc_val btfss PORTB,5 call dec_val movf temp,W movwf input2 btfss PORTB,7 return goto loop2 ;----------------------------------------------------------------- menu3 MOVLW 0C0h ; SET LINE CALL send_cmd ; SET IT movlw .05 ; For address org 0500h movwf PCLATH call msg3_3 clrw movwf PCLATH MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf input3,W movwf CHARACTER ; Display initial/previous value call disp3char loop3 movf input3,W movwf temp btfss PORTB,6 call inc_val btfss PORTB,5 call dec_val movf temp,W movwf input3 btfss PORTB,7 return goto loop3 ;----------------------------------------------------------------- menu4 MOVLW 0C0h ; SET LINE CALL send_cmd ; SET IT movlw .05 ; For address org 0500h movwf PCLATH call msg3_4 clrw movwf PCLATH MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf input4,W movwf CHARACTER ; Display initial/previous value call disp3char loop4 movf input4,W movwf temp btfss PORTB,6 call inc_val btfss PORTB,5 call dec_val movf temp,W movwf input4 btfss PORTB,7 return goto loop4 ;----------------------------------------------------------------- menu5 MOVLW 0C0h ; SET LINE CALL send_cmd ; SET IT movlw .05 ; For address org 0500h movwf PCLATH call msg3_5 clrw movwf PCLATH MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf input5,W movwf CHARACTER ; Display initial/previous value call disp3char loop5 movf input5,W movwf temp btfss PORTB,6 call inc_val btfss PORTB,5 call dec_val movf temp,W movwf input5 btfss PORTB,7 return goto loop5 ;----------------------------------------------------------------- menu6 MOVLW 0C0h ; SET LINE CALL send_cmd ; SET IT movlw .05 ; For address org 0500h movwf PCLATH call msg3_6 clrw movwf PCLATH MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf input6,W movwf CHARACTER ; Display initial/previous value call disp3char loop6 movf input6,W movwf temp btfss PORTB,6 call inc_val btfss PORTB,5 call dec_val movf temp,W movwf input6 btfss PORTB,7 return goto loop6 ;----------------------------------------------------------------- menu7 MOVLW 0C0h ; SET LINE CALL send_cmd ; SET IT movlw .05 ; For address org 0500h movwf PCLATH call msg3_7 clrw movwf PCLATH MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf input7,W movwf CHARACTER ; Display initial/previous value call disp3char loop7 movf input7,W movwf temp btfss PORTB,6 call inc_val btfss PORTB,5 call dec_val movf temp,W movwf input7 btfss PORTB,7 return goto loop7 ;----------------------------------------------------------------- menu8 MOVLW 0C0h ; SET LINE CALL send_cmd ; SET IT movlw .05 ; For address org 0500h movwf PCLATH call msg3_8 clrw movwf PCLATH MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf input8,W movwf CHARACTER ; Display initial/previous value call disp3char loop8 movf input8,W movwf temp btfss PORTB,6 call inc_val btfss PORTB,5 call dec_val movf temp,W movwf input8 btfss PORTB,7 return goto loop8 ;----------------------------------------------------------------- menu9 MOVLW 0C0h ; SET LINE CALL send_cmd ; SET IT movlw .06 ; For address org 0600h movwf PCLATH call msg_thresh clrw movwf PCLATH MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf input9,W movwf CHARACTER ; Display initial/previous value call disp3char loop9 movf input9,W movwf temp btfss PORTB,6 call inc_val btfss PORTB,5 call dec_val movf temp,W movwf input9 btfss PORTB,7 return goto loop9 ;----------------------------------------------------------------- menu10 MOVLW 0C0h ; SET LINE CALL send_cmd ; SET IT movlw .06 ; For address org 0600h movwf PCLATH call msg_sens clrw movwf PCLATH MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf input10,W movwf CHARACTER ; Display initial/previous value call disp3char loop10 movf input10,W movwf temp btfss PORTB,6 call inc_val btfss PORTB,5 call dec_val movf temp,W movwf input10 btfss PORTB,7 return goto loop10 ;----------------------------------------------------------------- menu11 MOVLW 0C0h ; SET LINE CALL send_cmd ; SET IT movlw .06 ; For address org 0600h movwf PCLATH call msg_del clrw movwf PCLATH MOVLW 0CDh ; SET LINE 2, start char. 14 CALL send_cmd ; SET IT movf input11,W movwf CHARACTER ; Display initial/previous value call disp3char loop11 movf input11,W movwf temp btfss PORTB,6 call inc_del btfss PORTB,5 call dec_del movf temp,W movwf input11 btfss PORTB,7 return goto loop11 ;*********************************************** ; initalise software ;*********************************************** init bcf STATUS,RP0 ;page 0 clrf PORTA clrf PORTB clrf PORTC clrf PORTD clrf PORTE PAGE1 movlw 0FFh movwf TRISB ;all pins inputs movwf TRISA ;all inputs clrf ADCON1 ; Set porta as analogue I/P's movwf TRISD ;all inputs movlw 07h movwf TRISE PAGE0 ; Set up USART PAGE1 bsf STATUS,RP0 ; goto page 1 movlw b'10000000' ; RC7 is RX input movwf TRISC movlw 01h ; 31250 baud for MIDI movwf SPBRG movlw b'00100000' ; async tx 8 bit movwf TXSTA bcf STATUS,RP0 ; return to page 0 movlw b'10010000' ; async rx 8 bit movwf RCSTA bsf STATUS,RP0 ; enable weak pull-up resistors movlw 07h ; rtcc/256 movwf OPTION_REG bcf STATUS,RP0 goto main ;---------------------------------------------------------------- ;**************************************************************** ; Main Programme ;**************************************************************** main call display_init btfsc PORTB,7 ; is Menu+ sw. pressed? goto main1 ; No, so go to Normal Mode main0 movlw 0x02 ; return home call send_cmd movlw 0x01 ; clear display call send_cmd movlw .05 ; For address org 0500h movwf PCLATH call msg1 ; Programme Mode clrw movwf PCLATH ;----------------------------------------------------------- ; Read previous variables midich and input 1-8 from EE_PROM ;----------------------------------------------------------- clrf base_addr ; start addr. of EEPROM at 00h? movf base_addr,W call ee_read movwf midich incf base_addr,F movf base_addr,W call ee_read movwf input1 incf base_addr,F movf base_addr,W call ee_read movwf input2 incf base_addr,F movf base_addr,W call ee_read movwf input3 incf base_addr,F movf base_addr,W call ee_read movwf input4 incf base_addr,F movf base_addr,W call ee_read movwf input5 incf base_addr,F movf base_addr,W call ee_read movwf input6 incf base_addr,F movf base_addr,W call ee_read movwf input7 incf base_addr,F movf base_addr,W call ee_read movwf input8 incf base_addr,F movf base_addr,W call ee_read movwf input9 incf base_addr,F movf base_addr,W call ee_read movwf input10 incf base_addr,F movf base_addr,W call ee_read movwf input11 incf base_addr,F ;+++++++++++++++++++++++++++++++++++++++++++++++++++++ sw0 btfsc PORTB,7 goto sw0 call menu0 sw1 btfsc PORTB,7 goto sw1 call menu1 sw2 btfsc PORTB,7 goto sw2 call menu2 sw3 btfsc PORTB,7 goto sw3 call menu3 sw4 btfsc PORTB,7 goto sw4 call menu4 sw5 btfsc PORTB,7 goto sw5 call menu5 sw6 btfsc PORTB,7 goto sw6 call menu6 sw7 btfsc PORTB,7 goto sw7 call menu7 sw8 btfsc PORTB,7 goto sw8 call menu8 sw9 btfsc PORTB,7 goto sw9 call menu9 sw10 btfsc PORTB,7 goto sw10 call menu10 sw11 btfsc PORTB,7 goto sw11 call menu11 ;------------------------------------------------------------- ; Write the variables midich and input 1-8 to EE_PROM ;------------------------------------------------------------- clrf base_addr ; start addr. of EEPROM at 00h? movf midich,W movwf temp_data call ee_write incf base_addr,F movf input1,W movwf temp_data call ee_write incf base_addr,F movf input2,W movwf temp_data call ee_write incf base_addr,F movf input3,W movwf temp_data call ee_write incf base_addr,F movf input4,W movwf temp_data call ee_write incf base_addr,F movf input5,W movwf temp_data call ee_write incf base_addr,F movf input6,W movwf temp_data call ee_write incf base_addr,F movf input7,W movwf temp_data call ee_write incf base_addr,F movf input8,W movwf temp_data call ee_write incf base_addr,F movf input9,W movwf temp_data call ee_write incf base_addr,F movf input10,W movwf temp_data call ee_write incf base_addr,F movf input11,W movwf temp_data call ee_write incf base_addr,F ;************************************** ; Main Programme Start in Normal Mode ; Read EEPROM and write to input1 to 8 ;************************************** main1 movlw 0x02 ; return home call send_cmd movlw 0x01 ; clear display call send_cmd movlw .06 ; For address org 0600h movwf PCLATH call msg4 ; Normal Mode clrw movwf PCLATH ;---------------------------------------------------- ; Read the variables midich and input 1-8 from EE_PROM ;----------------------------------------------------- clrf base_addr ; start addr. of EEPROM at 00h? movf base_addr,W call ee_read movwf midich incf base_addr,F movf base_addr,W call ee_read movwf input1 incf base_addr,F movf base_addr,W call ee_read movwf input2 incf base_addr,F movf base_addr,W call ee_read movwf input3 incf base_addr,F movf base_addr,W call ee_read movwf input4 incf base_addr,F movf base_addr,W call ee_read movwf input5 incf base_addr,F movf base_addr,W call ee_read movwf input6 incf base_addr,F movf base_addr,W call ee_read movwf input7 incf base_addr,F movf base_addr,W call ee_read movwf input8 incf base_addr,F movf base_addr,W call ee_read movwf input9 incf base_addr,F movf base_addr,W call ee_read movwf input10 incf base_addr,F movf base_addr,W call ee_read movwf input11 incf base_addr,F ;+++++++++++++++++++++++++++++++++++++++++++++++++++++ ;************************************** ; Main Programme Start ;************************************** main2 movfw input1 movwf drum ch0 movlw B'01000001' ; channel 0 movwf ADCON0 call drm_det movfw input2 movwf drum ch1 movlw B'01001001' ; channel 1 movwf ADCON0 call drm_det movfw input3 movwf drum ch2 movlw B'01010001' ; channel 2 movwf ADCON0 call drm_det movfw input4 movwf drum ch3 movlw B'01011001' ; channel 3 movwf ADCON0 call drm_det movfw input5 movwf drum ch4 movlw B'01100001' ; channel 4 movwf ADCON0 call drm_det movfw input6 movwf drum ch5 movlw B'01101001' ; channel 5 movwf ADCON0 call drm_det movfw input7 movwf drum ch6 movlw B'01110001' ; channel 6 movwf ADCON0 call drm_det movfw input8 movwf drum ch7 movlw B'01111001' ; channel 7 movwf ADCON0 call drm_det btfss PORTB,7 ; skip if prog sw. not pressed goto main0 ; go to programme mode goto main2 ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;---------------------------------------------------------------- ; New Origin, for Messages, with PCLATH set for return ;---------------------------------------------------------------- org 0500h ;****************************************************************** ; Use of a table to output a message ;****************************************************************** msg1 movlw 0 ;table address of start of message dispmsg1 movwf temp1 ;temp1 holds start of message address call table1 andlw 0ffh ;check if at end of message (zero btfsc STATUS,Z ;returned at end) return call send_char ;display character movf temp1,W ;point to next character addlw 1 goto dispmsg1 ;********************************************************** ; Table of data to be displayed ;************************************************************ table1 addwf PCL, f ;jump to char pointed to in w reg retlw ' ' retlw 'P' retlw 'R' retlw 'O' retlw 'G' retlw 'R' retlw 'A' retlw 'M' retlw 'M' retlw 'E' retlw ' ' retlw 'M' retlw 'O' retlw 'D' retlw 'E' retlw 0 ;****************************************************************** ; Use of a table to output a message ;****************************************************************** msg2 movlw 0 ;table address of start of message dispmsg2 movwf temp1 ;temp1 holds start of message address call table2 andlw 0ffh ;check if at end of message (zero btfsc STATUS,Z ;returned at end) return call send_char ;display character movf temp1,W ;point to next character addlw 1 goto dispmsg2 ;********************************************************** ; Table of data to be displayed ;************************************************************ table2 addwf PCL, f ;jump to char pointed to in w reg retlw 'M' retlw 'I' retlw 'D' retlw 'I' retlw ' ' retlw 'C' retlw 'h' retlw 'a' retlw 'n' retlw 'n' retlw 'e' retlw 'l' retlw ' ' retlw 0 ;****************************************************************** ; Use of a table to output a message ;****************************************************************** msg3_1 movlw 0 ;table address of start of message dispmsg3_1 movwf temp1 ;temp1 holds start of message address call table3_1 andlw 0ffh ;check if at end of message (zero btfsc STATUS,Z ;returned at end) return call send_char ;display character movf temp1,W ;point to next character addlw 1 goto dispmsg3_1 ;********************************************************** ; Table of data to be displayed ;************************************************************ table3_1 addwf PCL, f ;jump to char pointed to in w reg retlw ' ' retlw ' ' retlw 'D' retlw 'R' retlw 'U' retlw 'M' retlw ' ' retlw '1' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw 0 ;****************************************************************** ; Use of a table to output a message ;****************************************************************** msg3_2 movlw 0 ;table address of start of message dispmsg3_2 movwf temp1 ;temp1 holds start of message address call table3_2 andlw 0ffh ;check if at end of message (zero btfsc STATUS,Z ;returned at end) return call send_char ;display character movf temp1,W ;point to next character addlw 1 goto dispmsg3_2 ;********************************************************** ; Table of data to be displayed ;************************************************************ table3_2 addwf PCL, f ;jump to char pointed to in w reg retlw ' ' retlw ' ' retlw 'D' retlw 'R' retlw 'U' retlw 'M' retlw ' ' retlw '2' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw 0 ;****************************************************************** ; Use of a table to output a message ;****************************************************************** msg3_3 movlw 0 ;table address of start of message dispmsg3_3 movwf temp1 ;temp1 holds start of message address call table3_3 andlw 0ffh ;check if at end of message (zero btfsc STATUS,Z ;returned at end) return call send_char ;display character movf temp1,W ;point to next character addlw 1 goto dispmsg3_3 ;********************************************************** ; Table of data to be displayed ;************************************************************ table3_3 addwf PCL, f ;jump to char pointed to in w reg retlw ' ' retlw ' ' retlw 'D' retlw 'R' retlw 'U' retlw 'M' retlw ' ' retlw '3' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw 0 ;****************************************************************** ; Use of a table to output a message ;****************************************************************** msg3_4 movlw 0 ;table address of start of message dispmsg3_4 movwf temp1 ;temp1 holds start of message address call table3_4 andlw 0ffh ;check if at end of message (zero btfsc STATUS,Z ;returned at end) return call send_char ;display character movf temp1,W ;point to next character addlw 1 goto dispmsg3_4 ;********************************************************** ; Table of data to be displayed ;************************************************************ table3_4 addwf PCL, f ;jump to char pointed to in w reg retlw ' ' retlw ' ' retlw 'D' retlw 'R' retlw 'U' retlw 'M' retlw ' ' retlw '4' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw 0 ;****************************************************************** ; Use of a table to output a message ;****************************************************************** msg3_5 movlw 0 ;table address of start of message dispmsg3_5 movwf temp1 ;temp1 holds start of message address call table3_5 andlw 0ffh ;check if at end of message (zero btfsc STATUS,Z ;returned at end) return call send_char ;display character movf temp1,W ;point to next character addlw 1 goto dispmsg3_5 ;********************************************************** ; Table of data to be displayed ;************************************************************ table3_5 addwf PCL, f ;jump to char pointed to in w reg retlw ' ' retlw ' ' retlw 'D' retlw 'R' retlw 'U' retlw 'M' retlw ' ' retlw '5' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw 0 ;****************************************************************** ; Use of a table to output a message ;****************************************************************** msg3_6 movlw 0 ;table address of start of message dispmsg3_6 movwf temp1 ;temp1 holds start of message address call table3_6 andlw 0ffh ;check if at end of message (zero btfsc STATUS,Z ;returned at end) return call send_char ;display character movf temp1,W ;point to next character addlw 1 goto dispmsg3_6 ;********************************************************** ; Table of data to be displayed ;************************************************************ table3_6 addwf PCL, f ;jump to char pointed to in w reg retlw ' ' retlw ' ' retlw 'D' retlw 'R' retlw 'U' retlw 'M' retlw ' ' retlw '6' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw 0 ;****************************************************************** ; Use of a table to output a message ;****************************************************************** msg3_7 movlw 0 ;table address of start of message dispmsg3_7 movwf temp1 ;temp1 holds start of message address call table3_7 andlw 0ffh ;check if at end of message (zero btfsc STATUS,Z ;returned at end) return call send_char ;display character movf temp1,W ;point to next character addlw 1 goto dispmsg3_7 ;********************************************************** ; Table of data to be displayed ;************************************************************ table3_7 addwf PCL, f ;jump to char pointed to in w reg retlw ' ' retlw ' ' retlw 'D' retlw 'R' retlw 'U' retlw 'M' retlw ' ' retlw '7' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw 0 ;****************************************************************** ; Use of a table to output a message ;****************************************************************** msg3_8 movlw 0 ;table address of start of message dispmsg3_8 movwf temp1 ;temp1 holds start of message address call table3_8 andlw 0ffh ;check if at end of message (zero btfsc STATUS,Z ;returned at end) return call send_char ;display character movf temp1,W ;point to next character addlw 1 goto dispmsg3_8 ;********************************************************** ; Table of data to be displayed ;************************************************************ table3_8 addwf PCL, f ;jump to char pointed to in w reg retlw ' ' retlw ' ' retlw 'D' retlw 'R' retlw 'U' retlw 'M' retlw ' ' retlw '8' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw ' ' retlw 0 ;----------------------------------------------------------------------- org 0600h ;****************************************************************** ; Use of a table to output a message ;****************************************************************** msg4 movlw 0 ;table address of start of message dispmsg4 movwf temp1 ;temp1 holds start of message address call table4 andlw 0ffh ;check if at end of message (zero btfsc STATUS,Z ;returned at end) return call send_char ;display character movf temp1,W ;point to next character addlw 1 goto dispmsg4 ;********************************************************** ; Table of data to be displayed ;************************************************************ table4 addwf PCL, f ;jump to char pointed to in w reg retlw ' ' retlw ' ' retlw 'N' retlw 'O' retlw 'R' retlw 'M' retlw 'A' retlw 'L' retlw ' ' retlw 'M' retlw 'O' retlw 'D' retlw 'E' retlw 0 ;****************************************************************** ; Use of a table to output a message ;****************************************************************** msg_thresh movlw 0 ;table address of start of message dispmsg5 movwf temp1 ;temp1 holds start of message address call table5 andlw 0ffh ;check if at end of message (zero btfsc STATUS,Z ;returned at end) return call send_char ;display character movf temp1,W ;point to next character addlw 1 goto dispmsg5 ;********************************************************** ; Table of data to be displayed ;************************************************************ table5 addwf PCL, f ;jump to char pointed to in w reg retlw ' ' retlw ' ' retlw 'T' retlw 'H' retlw 'R' retlw 'E' retlw 'S' retlw 'H' retlw 'O' retlw 'L' retlw 'D' retlw ' ' retlw ' ' retlw 0 ;****************************************************************** ; Use of a table to output a message ;****************************************************************** msg_sens movlw 0 ;table address of start of message dispmsg6 movwf temp1 ;temp1 holds start of message address call table6 andlw 0ffh ;check if at end of message (zero btfsc STATUS,Z ;returned at end) return call send_char ;display character movf temp1,W ;point to next character addlw 1 goto dispmsg6 ;********************************************************** ; Table of data to be displayed ;************************************************************ table6 addwf PCL, f ;jump to char pointed to in w reg retlw ' ' retlw 'S' retlw 'E' retlw 'N' retlw 'S' retlw 'I' retlw 'T' retlw 'I' retlw 'V' retlw 'I' retlw 'T' retlw 'Y' retlw 0 ;****************************************************************** ; Use of a table to output a message ;****************************************************************** msg_del movlw 0 ;table address of start of message dispmsg7 movwf temp1 ;temp1 holds start of message address call table7 andlw 0ffh ;check if at end of message (zero btfsc STATUS,Z ;returned at end) return call send_char ;display character movf temp1,W ;point to next character addlw 1 goto dispmsg7 ;********************************************************** ; Table of data to be displayed ;************************************************************ table7 addwf PCL, f ;jump to char pointed to in w reg retlw ' ' retlw ' ' retlw ' ' retlw 'D' retlw 'E' retlw 'L' retlw 'A' retlw 'Y' retlw ' ' retlw 'm' retlw 'S' retlw ' ' retlw 0 end