Jump to content

PIC DMX receiver; assembler help sought


Tom Baldwin

Recommended Posts

I'm trying to write a DMX receiver using a Microchip PIC16F690 (PDF, 5MB).

 

I seem to be having trouble initialising the UART, and can't even get to the stage where RCSTA.FERR is set (framing error, which I take to mean break has been seen).

 

The following code is used to set the UART up:

; Serial port initialisation
bsf STATUS,RP1; Bank2
clrf ANSELH; clear analog selection bit AN11/RB5 (amongst others!)
bcf INTCON,GIE; disable global interrupts
bcf STATUS,RP1; back to Bank0
bsf STATUS,RP0; Bank1
bsf PIE1,RCIE; enable serial reception interrupts
movlw 0x04
movwf SPBRG; set baud rate (20MHz xtal)
bsf TXSTA,BRGH
bcf TXSTA,SYNC; select async
bcf STATUS,RP0; Bank0
bsf RCSTA,RX9; enable 9 bit reception - it's a frig to hide one of the stop bits in DMX
bcf RCSTA,ADDEN; no RS485-style address detection
bsf RCSTA,CREN; enable receive
bsf RCSTA,SPEN; enable serial port

 

I've looked at the signal on the RX pin, and it looks to be valid, with a break > 300us.

Digital scope trace, timebase 20us/div, 1V/div (signal is swinging rail to rail):

http://i119.photobucket.com/albums/o154/ipoints2000/157.jpg

The trigger point is the end of the break.

 

 

My code is a polling loop; I set one PORTC output when I check the RCSTA.FERR bit, and clear it again shortly afterwards. If FERR is set, another PORTC bit gets set. I can see the first output pulse at the expected frequency, but the second output never rises.

 

I assume I've failed to set the serial port up correctly, but really can't see what I've done wrong.

 

If anybody has experience of writing DMX receivers for PICs, and can shed some light, I'd appreciate a pointer.

Link to comment
Share on other sites

You have to read RCREG to clear the incoming FIFO, otherwise the UART can't receive anymore bytes.

You'll probably get more help from the Piclist that you will here. The topic of DMX comes up there from time to time, and you'll probably find what you're looking for in the archive.

 

Martin

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.