- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have the problem in the PUART baudrate setup.
This is my test environment.
SDK:2.2.2
Borad:TAG3 and Wiced sense
Serial Terminal: putty and AccessPort
Code:
#define GPIO_PUART_RX | 33 | //PUART RX PIN | |||||||
#define GPIO_PUART_TX | 32 | //PUART TX PIN | |||||||
#define UART_BAUD | 38400 | ||||||||
const BLE_PROFILE_PUART_CFG BLE_master_puart_cfg = { /*.baudrate =*/ UART_BAUD, /*.txpin =*/ GPIO_PUART_TX,//GPIO_PIN_UART_TX, /*.rxpin =*/ GPIO_PUART_RX,//GPIO_PIN_UART_RX, }; |
I use the API(puart_print) to print the test word in the end of create;
I try the different situations in puart baudrate.
situation1:
#define UART_BAUD 115200
Serial Terminal Baudrate:115200
AccessPort:
Putty:
When the baudrate is 15200,it work fine.
situation2:
#define UART_BAUD 38400
Serial Terminal Baudrate:115200 or 38400
AccessPort-38400
Putty-38400
AccessPort-115200
Putty-115200
When the baudrate of terminal is 38400,it will print strange word.
But I change baudrate into 115200,it work fine.
situation3:
#define UART_BAUD 9600
Serial Terminal Baudrate:115200 or9600
AccessPort-9600
Putty-9600
It have the same pattern in 38400.
I change the terminal into 115200,and puart can work.
I check the include file(ws_upgrade and ws_upgrade_uart),and I can't see any baudrate setup.
How can I slove the problem?
Solved! Go to Solution.
- Labels:
-
Peripherhal UART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Yu-Tzu
You need to call void puart_setBaudrate( UINT8 dhbr, UINT8 dlbr, UINT32 baudrate );
Look at puart.h
/// Set baud rate.
/// \param dhbr Internal. Should be 0x00.
/// \param dlbr Internal. Should be 0x00.
/// \param baudrate The desired baudrate.
void puart_setBaudrate( UINT8 dhbr, UINT8 dlbr, UINT32 baudrate );
Call it with 0,0,38400
Thanks
JT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was looking at puart_control.c and I found the below piece:
// Following structure defines UART configuration
const BLE_PROFILE_PUART_CFG puart_control_puart_cfg =
{
/*.baudrate =*/ 115200,
/*.txpin =*/ GPIO_PIN_UART_TX,
/*.rxpin =*/ GPIO_PIN_UART_RX,
};
The above shows the initialization of the baudrate to 115200. Your observations above showed that when the baudrate of the serial consoles matched that of the uart, the message was printed correctly. This made sense to me. Are you using any of the sample app? And do this only on the tag3 board.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi boont,
Thank you for your help.
My App is hello_client, and I modify the UART configuration structure.
Code:
#define GPIO_PUART_RX | 33 | //PUART RX PIN | |||||||
#define GPIO_PUART_TX | 32 | //PUART TX PIN | |||||||
#define UART_BAUD | 38400 | ||||||||
const BLE_PROFILE_PUART_CFG BLE_master_puart_cfg = { /*.baudrate =*/ UART_BAUD, /*.txpin =*/ GPIO_PUART_TX,//GPIO_PIN_UART_TX, /*.rxpin =*/ GPIO_PUART_RX,//GPIO_PIN_UART_RX, }; |
I check my include file again,I found default baud rate on the puart.h.
And I modify the baudrate,but the result is same.
/// Some useful default constants used by teh driver.
enum
{
P_UART_CLK = 24000000,
P_UART_SAMPLE_CLOCK = 16,
DEFAULT_P_UART_BAUDRATE = 115200,
DEFAULT_P_UART_HWFLOWCONTROLWATERMARK = 13, // Peer flow off waterline
DEFAULT_P_UART_MIN_PKT_LENGTH = 1
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi boont,
I look puart_control.c and ws_upgrade_uart again.
It is difference in initialization function between puart_control.c and ws_upgrade_uart.c.
This is my PUART initialization function.
if (!ws_upgrade_uart_init(&Hello_client_puart_cfg, application_puart_interrupt_callback)){ |
ble_trace0("UART Upgrade will not work check UART configuration\r\n");
}else{
puart_print("PUART initialization complete!\r\n"); |
}
But the baud rate setup isn't exist in the initialization function.
So I modify my PUART initialization function, and add the line.
puart_config.baudrate = puart_cfg->baudrate;
Now it work fine in serial terminal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Yu-Tzu
You need to call void puart_setBaudrate( UINT8 dhbr, UINT8 dlbr, UINT32 baudrate );
Look at puart.h
/// Set baud rate.
/// \param dhbr Internal. Should be 0x00.
/// \param dlbr Internal. Should be 0x00.
/// \param baudrate The desired baudrate.
void puart_setBaudrate( UINT8 dhbr, UINT8 dlbr, UINT32 baudrate );
Call it with 0,0,38400
Thanks
JT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi J.T,
Your solution look good.I will try it.
Thank for your help.
Michele