Hi
I’m new to MIOS and it’s a long time since I’ve worked with any assembler but it’s great fun.
I’m trying to develop code so that the MIDI command sent by a button will always act in the opposite sense to it’s corresponding DOUT. This is so the MIDI software on a PC (Miditzer) will get an off code when the DOUT is active and vice versa. The DOUTs will be controlled from the PC and not using FORWARDIO
I have three questions if someone would be kind enough to answer them.
1) When I get the state of a DOUT with MIDIO_DOUT_Get and it returns zero, does that mean that the DOUT pin is at 0V or is it in the non-active state (as defined in the .ini file, which could be 5V if invert is enabled)?
2) What variable holds the invert flag if I need to take it into account?
3) I lifted the code that gets the DIN status from another section on the MIDIO128 code. Is this piece of code the one to use?
Also, my congratulations on the quality of the code. I use it as an example for my students of high qualty internal documentation.
Thanks
Graham
Here is my code so far:
MIDIO_DIN_Toggle
;; when on: toggle between 0x00 and the DIN value defined in dump
;; when off: send nothing
IFSET TMP1, 0, rgoto MIDIO_DIN_NotifyChangeEnd
;; get the state of the DOUT corresponding to the current DIN
movf MIDIO_CURRENT_DIN, W
call MIDIO_DOUT_Get
movwf TMP1
;; TMP1 will now be 0 or non-zero depending on state of DOUT
;; I'm not sure which way around it is
;; get DIN status
call MIDIO_FSR_DINValue
movff MIDIO_CURRENT_DIN, WREG
call MIOS_HLP_GetBitORMask
andwf INDF0, W
;; W will now be 0 if the DIN will send an ON command
;; when it gets to MIDIO_DIN_Send
iorlw TMP1
;; W now holds 0 if the values are the both 0
;; so the next statement may be bnz rather than bz - not sure which
;; If an OFF DOUT returns zero then we need bz to turn it on.
;; we may also need to consider whether any INVERT flags are set by the .ini file
;; or whether the DOUT_Get takes that into account.
bz MIDIO_DIN_Send ; skip the toggle
;; toggle appr. bit in DIN_VALUE register
call MIDIO_FSR_DINValue
SET_BSR MIDIO_BASE
movf MIDIO_CURRENT_DIN, W, BANKED
call MIOS_HLP_GetBitORMask
xorwf INDF0, F
MIDIO_DIN_Send