2018-08-24 01:17 AM
2018-08-31 07:19 AM
The L073RZ is capable of using DMA for USART4, the VCOM.C is not illustrative of this, but there might be examples under the HAL trees.
STM32Cube_FW_L0_V1.10.0\Projects\STM32L073RZ-Nucleo\Examples\UART\UART_TwoBoards_ComDMA
2018-08-24 07:10 AM
Keil is an IDE, it does not really matter. It is like any other project. I recommend using STM32CubeMX tool which you can download for free.
https://www.st.com/en/development-tools/stm32cubemx.html
With it comes several examples and the tool can create a basic project for you.
2018-08-24 07:42 AM
I have Cubemx. Can you tell me how to specify serial port with Cubemx?
2018-08-24 08:19 AM
Just play with the Cube, you will see. It is not hard.
2018-08-24 08:46 AM
Which serial port on what pins?
You might be better looking at the existing vcom.c code, or the USART/UART examples under the HAL trees for the NUCLEO board.
2018-08-25 01:48 AM
In the example of p-nucleo-lrwan1 pingpong, I want to add code and set it to UART4 rx, tx . Please help me.
2018-08-25 02:25 AM
I want to set USART4 on pc10, pc11.
2018-08-25 08:59 AM
void USART4_Init(void)
{
static UART_HandleTypeDef UartHandle;
GPIO_InitTypeDef GPIO_InitStruct;
__USART4_CLK_ENABLE();
__GPIOC_CLK_ENABLE()
/* UART TX/RX GPIO pin configuration */
GPIO_InitStruct.Pin = GPIO_PIN_10 | GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF6_USART4;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*## Configure the UART peripheral ######################################*/
/* Put the USART peripheral in the Asynchronous mode (UART Mode) */
/* USART4 configured as follow:
- Word Length = 8 Bits
- Stop Bit = One Stop bit
- Parity = No parity
- BaudRate = 9600 baud
- Hardware flow control disabled (RTS and CTS signals) */
UartHandle.Instance = USART4;
UartHandle.Init.BaudRate = 9600;
UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
UartHandle.Init.StopBits = UART_STOPBITS_1;
UartHandle.Init.Parity = UART_PARITY_NONE;
UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
UartHandle.Init.Mode = UART_MODE_TX_RX;
if (HAL_UART_Init(&UartHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
// If you use interrupts
// HAL_NVIC_SetPriority(USART4_IRQn, 0x1, 0);
// HAL_NVIC_EnableIRQ(USART4_IRQn);
}
2018-08-26 04:57 AM
Thank you, but I'd like to use Interrupt but it says 'USART4_IRQn' is not defined. you help me?
2018-08-26 07:50 AM
L073RZ shares USART4 and 5 interrupts
HAL_NVIC_SetPriority(USART4_5_IRQn, 0x1, 0);
HAL_NVIC_EnableIRQ(USART4_5_IRQn);
..
void USART4_5_IRQHandler(void)
{
..
}