;-----------------------------------------------------------------------------------------------; ; Program: **tbd** ; ; Developed by David J. Brown ; ; Copyright (c) April 13, 2004 David J. Brown ; ; Email: davebr@earthlink.net ; ; Web site: http://modularsynthesis.com ; ;-----------------------------------------------------------------------------------------------; ; LICENSE AGREEMENT: ; ; This program is free software. You can redistribute it and/or modify it. ; ; ; ; This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, ; ; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;-----------------------------------------------------------------------------------------------; ; ; Description: ; This program **tbd** ; ; Inputs: ; Start = not used ; Stop = not used ; In-1 = not used ; In-2 = not used ; In-3 = not used ; In-4 = not used ; In-5 = not used ; In-6 = not used ; In-7 = not used ; In-8 = not used ; Aux = not used ; Midi-In = not used ; ; Outputs: ; Out-1 = not used ; Out-2 = not used ; Out-3 = not used ; Out-4 = not used ; Out-5 = not used ; Out-6 = not used ; Out-7 = not used ; Out-8 = not used ; Aux = not used ; Midi-Out= not used ; Speakjet= not used ; ; Display = not used ; Run led = toggles @ 0.5 S (timer interrupts enabled) ; Stop led= not used ; ; Revision: 0.0S2 ; Date Month Day, Year ; History: 0.0S2 initial release of program ; Written: Month Day, Year ; ;-----------------------------------------------------------------------------------------------; ; Conditionals ; ;-----------------------------------------------------------------------------------------------; ; ;---------PSIM, CVS, OR CVS-4 CONDITIONAL COMPILE OPTION----------------------------------------; ; ; ; UNCOMMENT ONE OF NEXT THREE LINES TO SELECT TARGET MODULE ; cvs con 1 ;define for CVS module ; ;cvs4 con 1 ;define for 4 channel CVS module ; ;psim con 1 ;define for PSIM module ; ;-----------------------------------------------------------------------------------------------; ;---------ENABLE AUX_IN RISING EDGE INTERRUPT CONDITIONAL COMPILE OPTION------------------------; ; ; ; COMMENT OUT NEXT LINE TO DISABLE AUX INPUT RISING EDGE INTERRUPTS ; aux_int_en con 1 ;define to enable aux_in rising edge interrupts ; ; ;comment to disable aux_in rising edge interrupts ; ;-----------------------------------------------------------------------------------------------; ;---------ENABLE TIMER INTERRUPT CONDITIONAL COMPILE OPTION-------------------------------------; ; Notes: run led will blink to verify timer operation ; ; ; ; COMMENT OUT NEXT LINE TO DISABLE TIMER INTERRUPTS ; timer_int_en con 1 ;define to enable timer interrupts ; ; ;comment to disable timer interrupts ; ; ; ; ;------ENABLE AVERAGED ANALOG-IN IN TIMER INTERRUPT CONDITIONAL COMPILE OPTION------------; ; ; ; Note: requires timer_int_en to be defined ; ; ; ; ; ; ; ; COMMENT OUT NEXT LINE TO DISABLE ANALOG-IN ON TIMER INTERRUPTS/ENABLE POLLED ANALOG-IN ; ; input_int_en con 1 ;define to enable input interrupt mode ; ; ; ; ;comment to set polled input mode ; ; ; ;-----------------------------------------------------------------------------------------; ; ; ; ; ;------ENABLE RISING EDGE DETECT IN TIMER INTERRUPT CONDITIONAL COMPILE OPTION------------; ; ; ; Note: requires timer_int_en to be defined ; ; ; ; pulse must be > 1 mS and > 8 mS period (7 timer clocks low / 1 timer clock high) ; ; ; ; ; ; ; ; COMMENT OUT NEXT LINE TO DISABLE RISING EDGE DETECT IN TIMER INTERRUPTS ; ; ; edge_int_en con 1 ;define to enable rising edge detect mode ; ; ; ; ;comment to disable rising edge detect mode ; ; ; ; UNCOMMENT ONE OF NEXT THREE LINES TO SELECT INPUT FOR RISING EDGE DETECT ; ; ; edge_in var in4 ;use start jack for rising edge detect input ; ; ; edge_in var in5 ;use stop jack for rising edge detect input ; ; ; edge_in var in8 ;use aux jack for rising edge detect input ; ; ; ;-----------------------------------------------------------------------------------------; ; ;-----------------------------------------------------------------------------------------------; ; ;-----------------------------------------------------------------------------------------------; ; Include Files (locate one level above the program directory) ; ;-----------------------------------------------------------------------------------------------; ; #include "..\support.djb.bas" ;support declarations and subroutines ; ;-----------------------------------------------------------------------------------------------; ; Program Declarations ; ;-----------------------------------------------------------------------------------------------; ; ;**tbd** ; ;-----------------------------------------------------------------------------------------------; ; Initialization ; ;-----------------------------------------------------------------------------------------------; ; initialize: ;program specific initialization starts here #ifdef psim pause 250 ;let display initialize hserout [$f0,$7d,$0a,$18,"0123456789ABCDEF",$f7] ;clear, overwrite, name #else hserout [$f0,$7d,$0a,$18,"0123456789ABCDEFFEDCBA9876543210",$f7] ;clear, overwrite, name #endif ;speak program name #ifdef psim i2cout i2c_data,i2c_clk,($48<<1),["i am rev 1.0",$02,"i was written by Dave Brown",$03,"ready",$0d] #endif ; ;-----------------------------------------------------------------------------------------------; ; Main Program ; ;-----------------------------------------------------------------------------------------------; ; ;sample program ; loop In1-4 to Out1-4 ; flash Stop led on Aux rising edge ; loop Midi In to Midi Out ;written by David J. Brown sample: if aux_cnt<>0 then ;flash stop led for each trigger on aux_in high stop_led disable let aux_cnt=0 ;reset aux count let turn_off=time_count+15 ;set flash time enable endif let out_j1=in_j1*15/4 ;pass in's to out's let out_j2=in_j2*15/4 let out_j3=in_j3*15/4 let out_j4=in_j4*15/4 let out_j5=in_j5*15/4 let out_j6=in_j6*15/4 let out_j7=in_j7*15/4 let out_j8=in_j8*15/4 gosub load_outputs gosub proc_midi ;pass midi in to out goto sample ; ;-----------------------------------------------------------------------------------------------; ; Subroutines ; ;-----------------------------------------------------------------------------------------------; ; ;subroutines here ; ;-----------------------------------------------------------------------------------------------; ; Interrupt Service Routines ; ;-----------------------------------------------------------------------------------------------; ; #ifdef aux_int_en ;interrupt service routine for aux input rising edge aux_isr: let aux_cnt=aux_cnt+1 ;count number of aux interrupts resume ;ignore overflow #endif ; ; #ifdef timer_int_en ;interrupt service routine for timer ;increments time_count value ;turn off stop led at turn_off value ;toggle run led at 512 mS intervals ;written by David J. Brown tm_isr: let time_count=time_count+1 ;increment real time count if time_count=turn_off then ;value to turn off stop led low stop_led endif let run_led_out=time_count.bit9 ;toggle run led at 512 mS intervals ; #ifdef edge_int_en ;check for trigger rising edge ;pulse width must be > 1 ms timer let edge_state=edge_state<<1 ;shift previous state left let edge_state.bit0=edge_in ;set low bit to current input state if edge_state=$01 then ;edge detect requires 7 previous lows and current high let edge_flg=1 ;set edge flag endif #endif ; #ifndef input_int_en resume ;resume if input polled mode #else ;sample in-1 - in-4 at specific intervals ;injx is input averaged over last 4 samples (0 - 1023) ;injx_bfr(0) & injx_bfr(1) are last 4 word samples ;written by David J. Brown let isr_cnt=isr_cnt+1 #ifdef cvs ;change the following table to modify the scan rate for each CVS input ;175 uS execution time so maximum of one sample and average per interrupt ;currently set for: in-1 to 8 @ 8 mS branch isr_cnt, [avg1,avg2,avg3,avg4,avg5,avg6,avg7,avg8,avg1,avg2,avg3,avg4,avg5,avg6,avg7,avg8] #else ;change the following table to modify the scan rate for each PSIM input ;175 uS execution time so maximum of one sample and average per interrupt ;currently set for: in-1 @ 2 mS, in-2 @ 4 mS, in-3 @ 8 mS, in-4 @ 8 mS branch isr_cnt, [avg1,avg2,avg1,avg3,avg1,avg2,avg1,avg4,avg1,avg2,avg1,avg3,avg1,avg2,avg1,avg4] #endif #endif #endif ;-----------------------------------------------------------------------------------------------; ; End Of Program ; ;-----------------------------------------------------------------------------------------------;