Uart parity issue.
Hi,
I am running a STML433 with external xtal. I have a serial port that works fine when I set the parity to NONE (I set the port to 9600 baud No parity 8bits 1stop bit). And works well , as expected. I have to set it to parity even (set to 9600 baud Even parity 8n bits 1 stop bit), so I set the register as follows:
USARTx->CR1 |= USART_CR1_PCE;// set parity
USARTx->CR1 &= ~USART_CR1_PS;// even parity
everything else in the uart is the same. But I dont get the correct info coming out of the serial port, the only way is if I set the terminal window on the receiving side to E 7 bits and 2 stop bits , which isnt any use. My complete setup is:
USARTx->CR1 &= ~USART_CR1_UE; //disable uart
USARTx->CR1 &= ~USART_CR1_M;// 8 bits
USARTx->CR2 &= ~USART_CR2_STOP;// 1 stop bit
if(Parity==NO_PARITY)
USARTx->CR1 &= ~USART_CR1_PCE;// no parity
else
{
//even only other option at the moment
USARTx->CR1 |= USART_CR1_PCE;// set parity
USARTx->CR1 &= ~USART_CR1_PS;// even parity
}
USARTx->CR1 &= ~USART_CR1_OVER8; //oversample
USARTx->BRR = 1666;
Anyone let me know what I am doing wrong? I am running the clock at 16MHz.
Many thanks
Scott
