STM32W108xx UART implementation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-02-26 1:10 AM
Hi
I want to show the output(i.e. sended data) on tera term terminal. How to setup tera term for that.(I am using UART for serial communication in which i am sending data from one port and receiving from other one.) Please reply me asap.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-02-26 6:41 AM
Attach cable, open window select COM port, baud rate, and parity/stop bit settings.
Perhaps you work with someone who can walk you through the basics?Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-02-26 8:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-02-26 10:19 AM
At least some of the STM32F108W parts have a USART.
The USART should function and program in a manner similar to other STM32F1 series parts. Have you reviewed some of the firmware examples? Which specific part are you using? What specific board are you using? Perhaps you can cite a schematic for your board. Perhaps you can get an EVAL series board from ST that has serial ports built on, and with which you can experiment before jumping in the deep end of the pool?Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-02-26 9:15 PM
Thanks for your reply.I am using STM32W108CBT6 in which UART having wired connectivity. I want to send and receive data through UART . Now tell me how to do that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-02-27 7:29 AM
// STM32W108 UART1 (PB.1 Tx, PB.2 Rx) sourcer32@gmail.com
#include ''stm32w108xx.h''
void outstring(char *s)
{
while(*s)
{
/* Loop until transmit data register is empty */
while (UART_GetFlagStatus(SC1_UART, UART_FLAG_TXE) == RESET);
UART_SendData(SC1_UART, (uint8_t)*s++);
}
}
int main(void)
{
UART_InitTypeDef UART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
/* Disable the serial controller interface */
UART_Cmd(SC1_UART, DISABLE);
/* Configure (PB1) UART Tx as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Set pull-up on UART Tx pin */
GPIO_SetBits(GPIOB, GPIO_Pin_1);
/* Configure (PB2) UART Rx as input with pull-up */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Set pull-up on UART Rx pin */
GPIO_SetBits(GPIOB, GPIO_Pin_2);
/* UARTx configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Hardware flow control disabled (RTS and CTS signals)
*/
UART_InitStructure.UART_BaudRate = 115200;
UART_InitStructure.UART_WordLength = UART_WordLength_8b;
UART_InitStructure.UART_StopBits = UART_StopBits_1;
UART_InitStructure.UART_Parity = UART_Parity_No;
UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_Disable;
/* UART configuration: Set up the parameters specific for the UART operating mode */
UART_Init(SC1_UART, UART_InitStruct);
/* Enable the UART peripheral */
UART_Cmd(SC1_UART, ENABLE);
while(1)
outstring(''Welcome to wherever you are!
'');
}
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-02-27 7:49 AM
Or with interrupts, something like this
// STM32W108 UART1 IRQ TX/RX Loop (PB.1 Tx, PB.2 Rx) sourcer32@gmail.com
#include ''stm32w108xx.h''
volatile char StringLoop[] = ''The quick brown fox jumps over the lazy dog
'';
/**************************************************************************************/
void SC1_IRQHandler(void)
{
static int tx_index = 0;
static int rx_index = 0;
if (UART_GetITStatus(SC1_IT, UART_IT_TXE) != RESET)
{
/* Write one byte to the transmit data register */
UART_SendData(SC1_UART, StringLoop[tx_index++]);
if (tx_index >= (sizeof(StringLoop) - 1))
tx_index = 0;
/* Clear the UART_IT_TXE pending interrupt, probably overkill */
UART_ClearITPendingBit(SC1_IT, UART_IT_TXE);
}
if (UART_GetITStatus(SC1_IT, UART_IT_RXNE) != RESET) // Received characters modify string
{
/* Read one byte from the receive data register */
StringLoop[rx_index++] = UART_ReceiveData(SC1_UART);
if (rx_index >= (sizeof(StringLoop) - 1))
rx_index = 0;
/* Clear the UART_IT_RXNE pending interrupt, probably overkill */
UART_ClearITPendingBit(SC1_IT, UART_IT_RXNE);
}
}
/**************************************************************************************/
void NVIC_Config(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable the SC1 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = SC1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
/**************************************************************************************/
int main(void)
{
UART_InitTypeDef UART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_Config();
/* Disable the serial controller interface */
UART_Cmd(SC1_UART, DISABLE);
/* Configure (PB1) UART Tx as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Set pull-up on UART Tx pin */
GPIO_SetBits(GPIOB, GPIO_Pin_1);
/* Configure (PB2) UART Rx as input with pull-up */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Set pull-up on UART Rx pin */
GPIO_SetBits(GPIOB, GPIO_Pin_2);
/* UARTx configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Hardware flow control disabled (RTS and CTS signals)
*/
UART_InitStructure.UART_BaudRate = 115200;
UART_InitStructure.UART_WordLength = UART_WordLength_8b;
UART_InitStructure.UART_StopBits = UART_StopBits_1;
UART_InitStructure.UART_Parity = UART_Parity_No;
UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_Disable;
/* UART configuration: Set up the parameters specific for the UART operating mode */
UART_Init(SC1_UART, UART_InitStruct);
/* Enable the UART peripheral */
UART_Cmd(SC1_UART, ENABLE);
/* Enable the SC1_IT Transmit interrupt: this interrupt is generated when the
UART transmit data register is empty */
UART_TriggerEventConfig(SC1_IT, UART_IT_TXE, SC_TriggerEvent_Level);
UART_ITConfig(SC1_IT, UART_IT_TXE, ENABLE);
/* Enable the SC1_UART Receive interrupt: this interrupt is generated when the
SC1_UART receive data register is not empty */
UART_ITConfig(SC1_IT, UART_IT_RXNE, ENABLE);
while(1);
}
/**************************************************************************************/
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-02-27 8:58 AM
Thanks for reply. But is it possible to watch the output on tera term terminal ? if yes then plz tell me how?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-02-27 10:15 AM
Thanks for reply. But is it possible to watch the output on tera term terminal ? if yes then plz tell me how?
Sure, I'm working on the premise ''I am using STM32W108CBT6 in which UART having wired connectivity'', so is it wired or not? How? Suggest you answer some of my previous questions.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-02-27 10:54 AM
Thanks for reply. Actuall on STM32W108CB UART is wired connected. But I am not connecting it. I want to show the sended packet on terminal.
