Mike Harrison wrote: > On Thu, 09 Nov 2006 16:23:51 -0700, you wrote: > > >> gus gusset wrote: >> >>> I'm trying to write a receiver for the theatrical >>> lighting control protocol DMX (8-bit async serial, 1 >>> start, 1 stop, 250kbaud). >>> > > That should be 2 stop, but this shouldn;t make a difference to a receiver > > >>> In order to detect break (>> 2x a single word), I am >>> polling RCSTA.FERR >>> >>> For debug, I turn PORTC,0 on when I enter this part of >>> the code, and clear it shortly afterwards. If were >>> ever to see an FERR, PORTC,3 would be set. Using a >>> scope, I can see that I do enter (and subsequently >>> leave) this part of the code, however, I never see >>> FERR. Note, I've seen other people's DMX-receiving >>> code; they use FERR to detect break. Unfortunately, I >>> can't find a substantive difference between their code >>> and mine (they are using different PICs). >>> >>> > > Are you polling for FERR BEFORE reading the byte from the UART? Reading the byte will clear FERR. > Are you remembering to take the byte from the uart after checking FERR? > > >> I wrote a DMX handler too. I was not aware that FERR was meant to >> detect a break. >> > > Not 'meant to' but a very convenient way to do so. > FERR happens if the line is asserted during the stop bit, so this will happen on a break. > Works fone on AVRs and unless there is something peculiar about the PIC's UART I would expect it to > work just the same. > > >> What I did to detect the break is to simply allow a short timer to timeout >> whenever serial characters failed to be received; when a character WAS >> received, the timer was preset. It then counted down using the TIMR1 >> interrupt. It was quite precise, and would detect the break before >> being too far into it. I set the timer to timeout when two character bit >> times >> failed to arrive. At 250KB, that was 20/250kb. >> > > I don't think DMX defines maximum inter-character gaps within a frame, so wouldn't this scheme > detect false breaks if there were gaps between bytes within a frame? > > It was not defined, but in fact I never saw the DMX sender ever take a break between characters. I made my detect circuit fast because I needed to use the break to catch up on routine data updates. --Bob > > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist