uart baud rate ?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

uart baud rate ?

2,772件の閲覧回数
aravindpb5009
Contributor III

hai 

        in my Lpc824 have 3 uart protocol   . can i use the uart0 in 9600 baud rate and the uart1 as 115200 , if it is possible to use different baud rates in single code

Thanks&Regards

Aravind P

ラベル(6)
0 件の賞賛
返信
1 返信

2,490件の閲覧回数
soledad
NXP Employee
NXP Employee

Hi, 

Yes, it is possible.

 All three USARTs use a common peripheral clock (U_PCLK) and, if needed, a fractional baud rate generator.

In asynchronous mode, it is necessary to configure the baud rate divider BRGVAL in the USARTn BRG register and the serial clock is Un_SCLK.

pastedImage_1.png

If you are using the SDK, this funtion initializes the USART configuration structure to a default value. The default values are:


* usartConfig->baudRate_Bps = 9600U;
* usartConfig->parityMode = kUSART_ParityDisabled;
* usartConfig->stopBitCount = kUSART_OneStopBit;
* usartConfig->bitCountPerChar = kUSART_8BitsPerChar;
* usartConfig->loopback = false;
* usartConfig->enableTx = false;
* usartConfig->enableRx = false;


void USART_GetDefaultConfig(usart_config_t *config)
{
/* Check arguments */
assert(NULL != config);

/* Initializes the configure structure to zero. */
memset(config, 0, sizeof(*config));

/* Set always all members ! */
config->baudRate_Bps = 9600U;
config->parityMode = kUSART_ParityDisabled;
config->stopBitCount = kUSART_OneStopBit;
config->bitCountPerChar = kUSART_8BitsPerChar;
config->loopback = false;
config->enableRx = false;
config->enableTx = false;
config->syncMode = kUSART_SyncModeDisabled;
config->enableContinuousSCLK = false;
config->clockPolarity = kUSART_RxSampleOnFallingEdge;
}

So you can modify it according to your needs, for example: 

USART_GetDefaultConfig(&config);
config.enableRx = true;
config.enableTx = true;
config.baudRate_Bps = 115200;

/* Initialize the USART with configuration. */
USART_Init(USART1, &config, EXAMPLE_USART_CLK_FREQ);

I hope this helps, 

Have a nice day!

0 件の賞賛
返信