In SX Microcontrollers, SX/B Compiler and SX-Key Tool, rodneymc wrote: I have a question for someone to help shed some light for me... Below is the SX/B ASM code output for the SEROUT (OT) function. I'm understanding what's going on except for why the [b]CLRB MidiOut[/b] is needed after the [b]MOV !RA,IND[/b] in the code below. It seems to be doing the same thing, and works without it, but was wondering if I was not realizing something for leaving it out? Maybe it's needed to cover off on the other modes? It's only one cycle, but again the curiosity strikes me. [code] ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- MidiOut VAR RA.1 '..... MOV __PARAM1,#NN ';SEROUT MidiOut, MidiBaud, NN (sx/b) MOV __PARAM2,#10 '#bits MOV FSR,#__TRISA 'get the i/o states MODE $0F 'set for i/0 CLRB IND.1 'This gets bit 1 ready to toggle to 0 (input or 0 for Open Collector) for Start Bit = 0 MOV !RA,IND 'RA.1 to 0 (input) (but sets all 4 ports) [b]CLRB MidiOut 'RA.1 to 0? Why would this statement be needed here? Didn't CLRB IND.1 take care of this?[/b] MOV __PARAM4,#126 'baud rate loop DJNZ __PARAM4,@$ MOVB IND.1,__PARAM1.0 'this gets the next bit ready for bits 0-8 + stop bit MOV !RA,IND 'output the bit (but sets all 4 ports) STC 'set carry for stop bit RR __PARAM1 'rotate right to move next bit into LSB DJNZ __PARAM2,@$-13 BANK $00 [/code] [b]Bean[/b], after realizing what was going on, I must commend you as this a brilliant way to do the open collector simulation! Toggling the TRIS bit to input or output related to the port for 1 or 0 - wow! Many thanks! Rodney ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=287096 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)