SERIN/OUT Baud Modes Clarification
Can someone help me clarify what·does the "OPEN"·refer to·for the baud modes in SERIN/OUT?
I had thought it was·"Open Collector" but doesn't seem to be, looking at the·asm code.
Here's the difference's in assembly of a subroutine·I'm using·- taking a quick look, it seems to·inverse the data !RA, but I thought that's what the "N" (inverted) was used for...
BAUD = "OTnnnn"
··
BAUD = "Tnnnn"
Thanks!
Rodney·
I had thought it was·"Open Collector" but doesn't seem to be, looking at the·asm code.
Here's the difference's in assembly of a subroutine·I'm using·- taking a quick look, it seems to·inverse the data !RA, but I thought that's what the "N" (inverted) was used for...
BAUD = "OTnnnn"
293 0092 0425 CLRB MyOut 294 0093 0C7E MOV __PARAM4,#126 0094 002B 295 0095 02EB DJNZ __PARAM4,@$ 0096 0010 0A95 296 0098 0708 MOVB IND.1,__PARAM1.0 0099 0420 0608 0520 297 009C 0200 MOV !RA,IND 009D 0005 298 009E 0503 STC 299 009F 0328 RR __PARAM1 300 00A0 02E9 DJNZ __PARAM2,@$-13 00A1 0010 0A93 301 00A3 0018 BANK $00
··
BAUD = "Tnnnn"
293 0092 0018 BANK $00 294 0093 0425 CLRB MyOut 295 0094 0C7E MOV __PARAM4,#126 0095 002B 296 0096 02EB DJNZ __PARAM4,@$ 0097 0010 0A96 297 0099 0000 NOP 298 009A 0000 NOP 299 009B 0708 MOVB MyOut,__PARAM1.0 009C 0425 0608 0525 300 009F 0503 STC 301 00A0 0328 RR __PARAM1 302 00A1 02E9 DJNZ __PARAM2,@$-13 00A2 0010 0
Thanks!
Rodney·
Comments
!RA is the TRIS port (IO direction) for RA -- not the inverted data of RA. The reason the code grabs the "shadow" tris port is that the SX28 does not allow direct reads of tris, and the code has to ensure that the IO state of the other pins is not affected by the SEROUT. In the end, the stop bit (1) will cause the IO pin to float.
Post Edited (JonnyMac) : 7/21/2008 9:02:57 PM GMT
It made me realize I need to not (!)·assume with assembler!
I've been using the simulator to see what's happening, but I'm still not sure on·how does the SX 'know' that the output port is open collector?
Is it because the output port is·initialized as an input, and then it 'outputs' with·mov !RA, IND command, instead of using TRIS_A = %0000 where the program starts?
Where all of this is leading is using open collector for MIDI out on the UART VP.
I just can't get my head around this yet!· I figure if I can see what Bean is doing with SX/B, I can do the same with the UART VP.
the UART VP·has the following code for the output configuration:
So, for TRIS, if 1 = input, 0 = output
Port·2 is initialized as an output, and then set as an input
Port 3 is initialized as an input, and then set as an output
I'm not sure why·he's doing this...can anyone add any enlightenment for me?··(of course those are the only two lines that Gunther doesn't touch upon).
I have midiout working using SEROUT, and declaring the Tx pin as a var
So, that would lead me to think I that I need to have my UART VP Tx·output defined as inputs, for Open Collector.
Am I making this too complicated?
Many thanks for any feedback!
Rodney, the MIDIot
Why an open collector output for MIDI? MIDI uses a current loop with optical couplers, so by its construction there is electrical isolation; driving the outputs both directions will not harm a properly-constructed MIDI system.
[noparse][[/noparse]Edit] In the event you really need open-collector output I've attached a framework that should get you going.
[noparse][[/noparse]Edit] Fixed DELAY_MS subroutine; uses ISR timing now.
Post Edited (JonnyMac) : 7/23/2008 7:54:50 PM GMT
I apologize for being in this rut, but as far as open collector, isn't that what "O" is for in the baud mode?
All of the Basic Stamp MIDI code has this as well.
I guess I'm thinking too much again, but wouldn't a·current loop require it to be open collector on TX, as the Rx is optically isolated?
I also found several references, here's one noting this:
MIDI IN :
· 1- n.c.
··4- anode of optocoupler
··2- n.c. <<<--- !!!! Different for MIDI OUT
··5- cathode of optocoupler
··3- n.c.
MIDI OUT/THRU:
· 1- n.c.
··4- +5v thru resistor
··2- local ground
··5- TTL open collector output
··3- n.c.
Basically, through my experiments, if I specify my TXOut as "output", it freaks out my synth.· If I leave as input, and do SEROUT "OT", it works!
It also freaks out when I use the "PIN OUTPUT" reference, but· "PIN INPUT" works fine. (e.g. using PIN INPUT, and using·SEROUT on the input pin)
Hence, I'm thinking there's something similar going on w/ the·UART VP, and can't get my head around the OC thing.
All of my 'commerical' midi devices work great on this synth.· I'll post my findings when I get there, but sounds like you're already successful with this, which leads me to think I'm heading down a wrong path...·which isn't so bad, as long·as I'm having fun and have great interaction w/ the forum members!
Your (and anyone else's)·input is much appreciated!
Thanks!
Rodney
Yes, the "O" is for Open, it's the next letter that counts. For MIDI using high-level SEROUT you need to specify a baud parameter of OT31250; the T indicates True mode where the idle state of the line is 1 (which is usually pulled up in Open mode), this is akin to Open-Collector (though it's actually called Open-Source in the SX due to the construction of the IO pin).
It might be helpful if you posted your entire program -- sometimes working with fragments can put the rest of us at a serious disadvantage.
[noparse][[/noparse]Edit] Since I chided you about posting a program, I've attached a simple MIDI program that uses high-level code (not test, I don't have a MIDI instrument).
Post Edited (JonnyMac) : 7/23/2008 7:53:56 PM GMT
Another point to this is that I'm not using the two inverters/buffers on the MIDI spec for the TxOut (the latter one is a 75LS05, which is open collector), as I'm assuming that the SX can be used w/o them... I'm reducing parts, but I need to experiment a bit more, as that could be part of my problem...
I think I know where to go from here - I will definately provide feedback...
Can you help me understand what you mean by? Isn't this referring to·two different types of buffers?· I consider the inverters a buffer to protect the processor data lines - (e.g. for appropriately sinking/sourcing the current, or enabling OC on a uart/processor pin that doesn't have it), whereas buffering the data through the processor is temporarily storing the data, until it can be appropriately·used (as in the Rx UART VP).· ····· Wouldn't a 5mA current loop be 5mA no matter what?·· Looking at the schematic from Midi out to Midi in, you have 5v supply, a 220 ohm resister, a diode voltage drop (opto coupler·- assume 0.7v), and two more 220 ohm resistors.··· This would be 4.3V/660 ohms = 6.5mA, unless I'm missing something...
My project will eventually use both Midi TX and RX - something like an simple arpeggiator initially.
I'm·focusing on the Midi TX part (using the VP).· The Rx you have already·done for us (many thanks for that!)
Sorry for stretching this thread out beyond its initial context, and again appreciate the·help!
Rodney
·
My mistake on the MIDI loop current; sorry, it is much less than 20 mA (I calculate 7.9 mA).
To be candid, I think this thread has become somewhat long-winded because you present everything in fragments, not allowing the rest of us to see the whole picture -- that makes things tough....
Thanks!