Hello everyone and a BIG THANX to motogeek for posting this: http://gcbasic.sourceforge.net/Typesetter/index.php/Driving-a-bunch-of-relays-using-one-pin-on-pic
but i have a question about one line in his code where he specifies the serial comm parameters for his processor:
"TXSTA = 0b01100101 ' 9 bit data (TX9 = 1), TXEN = 1, high speed (BRGH = 1), place for 9th bit = 1 (TX9D = 1)"
he is saying 9 bit data, but wikipedia says:
"At the datalink layer, a DMX512 controller transmits asynchronous serial data at 250 kbit/s. The data format is fixed at one start bit, eight data bits (least significant first[7]), two stop bits and no parity."
since it's clear that his code works, i wanna know what to specify for an atmega2560 so i'll get the same serial pattern.
thanx, mike
Last edit: louie 2018-04-12
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This took a little ferreting out but i think this is the solution.
DMX asynch serial is as you pointed out 250kb &"one start bit, eight data bits (least significant first[7]), two stop bits and no parity".
PIC's don't do parity with anything built in, GCB has Not implemented parity yet on the HSer. The 9th bit is turned on in motogeeks code, so why? Well, above we said we needed 2 stop bits. so the 9th bit is acting as a stop bit.
2560 can also do 9 bits but a nice feature of the 2560 usart is ability to do 2 stop bits. Look at the UCSRnC register bit #3 . In GCB to turn that bit on in config just use
USBS1 = 1 ' turns on 2 stop bits
The 1 in the bit name USBS1 is the channel. 2560 has 4 channels 0,1,2,3. choose wisely.
Replace:
"RCSTA = 0b01010000 ' serial port disabled (SPEN = 0), 9 bit data (RX9 = 1) not sure if needed here in RX
TXSTA = 0b01100101 ' 9 bit data (TX9 = 1), TXEN = 1, high speed (BRGH = 1), place for 9th bit = 1 (TX9D = 1)"
with
USBS1 = 1
baud rate should be calculated fine.
Your not doing any receive so leave it default.
GL
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi mmotte, I enable and disable the uart so I can make the long break using the same TX pin. The long break indicates the start of the DMX sequence. This was the only way I could think of to do that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello guys i'm recovering from the flu.
thanx for clearing it up.
i'm doing this to configure the parameters:
UCSR0C = 0b00001011 ' Async, no parity, 2 stop bits, 8 bits
is this: TXEN0 = 0
the same as this?: UCSR0B = UCSR0B and 0b11110111 ' disable TX, since the TXEN is bit 3
and i have to use port0 because my shield is wired to that port. and the shield has jumpers on it so i can disconnect lines TX0 and RX0 when i'm connecting usb.
Last edit: louie 2018-04-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
UCSR0C = 0b00001011 ' Async, no parity, 2 stop bits, 8 bits
Looks right
is this: TXEN0 = 0
the same as this?: UCSR0B = UCSR0B and 0b11110111 ' disable TX, since the TXEN is bit 3
Is the same. But TXEN0 = 0 is easier, thankyou compiler for raising us up.
GL
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everyone and a BIG THANX to motogeek for posting this: http://gcbasic.sourceforge.net/Typesetter/index.php/Driving-a-bunch-of-relays-using-one-pin-on-pic
but i have a question about one line in his code where he specifies the serial comm parameters for his processor:
"TXSTA = 0b01100101 ' 9 bit data (TX9 = 1), TXEN = 1, high speed (BRGH = 1), place for 9th bit = 1 (TX9D = 1)"
he is saying 9 bit data, but wikipedia says:
"At the datalink layer, a DMX512 controller transmits asynchronous serial data at 250 kbit/s. The data format is fixed at one start bit, eight data bits (least significant first[7]), two stop bits and no parity."
since it's clear that his code works, i wanna know what to specify for an atmega2560 so i'll get the same serial pattern.
thanx, mike
Last edit: louie 2018-04-12
This took a little ferreting out but i think this is the solution.
DMX asynch serial is as you pointed out 250kb &"one start bit, eight data bits (least significant first[7]), two stop bits and no parity".
PIC's don't do parity with anything built in, GCB has Not implemented parity yet on the HSer. The 9th bit is turned on in motogeeks code, so why? Well, above we said we needed 2 stop bits. so the 9th bit is acting as a stop bit.
2560 can also do 9 bits but a nice feature of the 2560 usart is ability to do 2 stop bits. Look at the UCSRnC register bit #3 . In GCB to turn that bit on in config just use
The 1 in the bit name USBS1 is the channel. 2560 has 4 channels 0,1,2,3. choose wisely.
Replace:
"RCSTA = 0b01010000 ' serial port disabled (SPEN = 0), 9 bit data (RX9 = 1) not sure if needed here in RX
TXSTA = 0b01100101 ' 9 bit data (TX9 = 1), TXEN = 1, high speed (BRGH = 1), place for 9th bit = 1 (TX9D = 1)"
with
USBS1 = 1
baud rate should be calculated fine.
Your not doing any receive so leave it default.
GL
Mike
I see one more thing. motogeek is enabling and disabling the HSer port in the transDMX sub.
I would try with these commented out.
but if you need them then on the 2560 TXEN1 is the bit to set and reset. here again in the name TXEN1 the 1 is the serial port (0,1,2,3).
GL
Mike
Hi mmotte, I enable and disable the uart so I can make the long break using the same TX pin. The long break indicates the start of the DMX sequence. This was the only way I could think of to do that.
Hello guys i'm recovering from the flu.
thanx for clearing it up.
i'm doing this to configure the parameters:
UCSR0C = 0b00001011 ' Async, no parity, 2 stop bits, 8 bits
is this: TXEN0 = 0
the same as this?: UCSR0B = UCSR0B and 0b11110111 ' disable TX, since the TXEN is bit 3
and i have to use port0 because my shield is wired to that port. and the shield has jumpers on it so i can disconnect lines TX0 and RX0 when i'm connecting usb.
Last edit: louie 2018-04-13
UCSR0C = 0b00001011 ' Async, no parity, 2 stop bits, 8 bits
Looks right
is this: TXEN0 = 0
the same as this?: UCSR0B = UCSR0B and 0b11110111 ' disable TX, since the TXEN is bit 3
Is the same. But TXEN0 = 0 is easier, thankyou compiler for raising us up.
GL
Mike
yeah that's a nice touch. thanx