Jump to content

spitting j5 into 4 out / 4 Ain


Alkex
 Share

Recommended Posts

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 insight

Best regards

Alex

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...