Alkex Posted November 15, 2008 Report Share Posted November 15, 2008 Hi,I'm using a midibox cv to midify a Moog rogue but would love to convert the synth's cv out into midi using an analog input.Right now, I am usgin port J5 as Dout for trigger but only need the first 2 pins as outputs.Is it easy to redefine say pins 3 to 8 of J5 as analog inputs?Thanks in advance for your insightBest regardsAlex Quote Link to comment Share on other sites More sharing options...
stryd_one Posted November 15, 2008 Report Share Posted November 15, 2008 Yeh it's not too rough. You set the appropriate TRISx bits to 1, and configure the ADC accordingly (unmuxed). Quote Link to comment Share on other sites More sharing options...
Alkex Posted November 15, 2008 Author Report Share Posted November 15, 2008 thanks stryd_oneI don't want to sound lazy but please could you paste me an example code if you have one so i can put your explanation to code. I've never tried programming beyond the Mios functionsThanks Quote Link to comment Share on other sites More sharing options...
stryd_one Posted November 16, 2008 Report Share Posted November 16, 2008 Edit: don't use this yet...... I gotta check one more thing....I went to try this and found that TK left you a hint:j5_dout.inc: J5_DOUT_Init ;; disable the ADC which allocates the analog pins ;; removed ;; movlw 0x07 ;; movwf ADCON1 ;; turn on the output driver of PORTA and PORTE ;; (note: if you want to use some of them as input instead, just set the appr. line to "bsf TRISx, x" ;; first 6 pins reassigned as AINs bsf TRISA, 0 ; Pin RA.0 = ain bsf TRISA, 1 ; Pin RA.1 = ain bsf TRISA, 2 ; Pin RA.2 = ain bsf TRISA, 3 ; Pin RA.3 = ain bsf TRISA, 5 ; Pin RA.5 = ain bsf TRISE, 0 ; Pin RE.0 = ain ;; last two are still DOUTs bcf TRISE, 1 ; Pin RE.1 = output bcf TRISE, 2 ; Pin RE.2 = output return Then in main.inc: USER_Init ....... ;; initialize J5 for driving LEDs if enabled #if ENABLE_J5 call J5_DOUT_Init #endif ;; initialise AINs. BE SURE TO EDIT j5_dout.inc !! movlw 0x06 call MIOS_AIN_NumberSet call MIOS_AIN_UnMuxed ........ Then throw your stuff in USER_AIN_NotifyChange ;; your code here return I *think* that will work. Check my work, because ****ing this up can result in a short and nuked PIC. Quote Link to comment Share on other sites More sharing options...
stryd_one Posted November 16, 2008 Report Share Posted November 16, 2008 Okay there was one thing I wasn't sure I'd gotten right, and it turns out that it depends on which PIC you're using. In the code above, right at the top, is this: J5_DOUT_Init ;; disable the ADC which allocates the analog pins ;; removed ;; movlw 0x07 ;; movwf ADCON1 If you have a 4620/4685/etc (newer chip) then make it this: J5_DOUT_Init ;; AN0...AN5 AINs, and AN6,7 DINs movlw 0x09 movwf ADCON1 If it's a 452 ... uhm... Pretty sure that we want J5_DOUT_Init ;; AN0...AN5 AINs, and AN6,7 DINs movlw 1 << ADFM) | (1 << ADCS2) | 0x09 movwf ADCON1 Oh, in case you didn't notice, you have to use the AINs for the first 6 pins on the port, and the remainder can be DOUTs. BTW, if you want to use more or less pins, these ADCON1 values will change. You can find tables in the PIC datasheets that describe what ADCON1 values will do. Quote Link to comment Share on other sites More sharing options...
Alkex Posted November 19, 2008 Author Report Share Posted November 19, 2008 Thanks so much for your time. I will try this asap! This is really going to add excitement to my moog!Thanks againAlex Quote Link to comment Share on other sites More sharing options...
stryd_one Posted November 19, 2008 Report Share Posted November 19, 2008 Just ahh... Check my work, because ****ing this up can result in a short and nuked PIC. ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.