MCF5213 multidrop mode, how to transmit 9 bit

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

MCF5213 multidrop mode, how to transmit 9 bit

跳至解决方案
2,236 次查看
mstone59
Contributor II

Hello,

I am trying to implement a 9-bit protocol on the 5213. I have the receiver working fine, but the transmitter I can't get to add the 9th bit, 1 for first char of msg, 0 for the rest of msg. I'm setting the PM & PT bits in the mode register to address for the first char, then data for the rest, but the bit won't change. Does anyone have an example or know how to do this?

Thank You,

Mike

标签 (1)
0 项奖励
回复
1 解答
1,217 次查看
mjbcswitzerland
Specialist V

Hi Mike

 

To do this you need to allow the first byte (with settings PM=11 and PT=1) to be transmitted.

When this has completd (eg. its interrupt arrives) you can change the setting and send the next byte. It does say in the manual that the change must be performed before the transmitter is enabled and before the next byte has been copied, but it works the same disabling the transmitter or not.

 

To change the mode, you have to be careful with the UMR1 register since it has to be selected before access. It is often easiest to keep a backup of the register content since any read/write will cause the internal pointer to increment to UMR2, thus making changes like UMR1 |= 0x01; impossible.

 

The sequence is

 

*UCR_X = UART_RESET_CMD_PTR;      // reset the internal pointer to UMR1 (rather than URM2)

*UMR1_2_X = (UART_NO_PARITY | UART_MULTIDROP | UART_8_BIT); // value eg. 0x1b for data mode

Then send the next character as normal.

 

To set the address mode back

*UCR_X = UART_RESET_CMD_PTR;     // reset the internal pointer to UMR1 (rather than URM2)

*UMR1_2_X = (UART_NO_PARITY | UART_MULTIDROP | UART_8_BIT | ADD_CHAR); // value eg. 0x1f for address mode

Then send the address character.

 

This mode is not suitable for DMA transmission since the change needs to be made actively in code between characters.

 

Good luck

 

Regards

 

Mark

 

www.uTasker.com

 

 

 

 

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,218 次查看
mjbcswitzerland
Specialist V

Hi Mike

 

To do this you need to allow the first byte (with settings PM=11 and PT=1) to be transmitted.

When this has completd (eg. its interrupt arrives) you can change the setting and send the next byte. It does say in the manual that the change must be performed before the transmitter is enabled and before the next byte has been copied, but it works the same disabling the transmitter or not.

 

To change the mode, you have to be careful with the UMR1 register since it has to be selected before access. It is often easiest to keep a backup of the register content since any read/write will cause the internal pointer to increment to UMR2, thus making changes like UMR1 |= 0x01; impossible.

 

The sequence is

 

*UCR_X = UART_RESET_CMD_PTR;      // reset the internal pointer to UMR1 (rather than URM2)

*UMR1_2_X = (UART_NO_PARITY | UART_MULTIDROP | UART_8_BIT); // value eg. 0x1b for data mode

Then send the next character as normal.

 

To set the address mode back

*UCR_X = UART_RESET_CMD_PTR;     // reset the internal pointer to UMR1 (rather than URM2)

*UMR1_2_X = (UART_NO_PARITY | UART_MULTIDROP | UART_8_BIT | ADD_CHAR); // value eg. 0x1f for address mode

Then send the address character.

 

This mode is not suitable for DMA transmission since the change needs to be made actively in code between characters.

 

Good luck

 

Regards

 

Mark

 

www.uTasker.com

 

 

 

 

0 项奖励
回复
1,217 次查看
mstone59
Contributor II

Mark,

 

That did it! I forgot to reset the mode register pointer. Thank you very much!

 

Kind Regards,

Mike Stone

0 项奖励
回复