Friday 29 January 2016

stm32 - USART6 STM32F746NG isn't working


I'm having trouble configuring the USART6 in my STM32F746NG. I am setting up the USART6 to enable UART comunication, using the code below to initiate it and also create an echo function.


    __USART6_CLK_ENABLE();


GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.Pin = GPIO_PIN_7;
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
GPIO_InitStructure.Alternate = GPIO_AF8_USART6;
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;

GPIO_InitStructure.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIO_InitStructure.Pin = GPIO_PIN_6;
GPIO_InitStructure.Mode = GPIO_MODE_AF_OD;
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);

static UART_HandleTypeDef s_UARTHandle;

s_UARTHandle.Instance = USART6;

s_UARTHandle.Init.BaudRate = 115200;
s_UARTHandle.Init.WordLength = UART_WORDLENGTH_8B;
s_UARTHandle.Init.StopBits = UART_STOPBITS_1;
s_UARTHandle.Init.Parity = UART_PARITY_NONE;
s_UARTHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
s_UARTHandle.Init.Mode = UART_MODE_TX_RX;
HAL_USART_Init(&s_UARTHandle);

char generic_buffer;


for (;;)
{
HAL_UART_Receive(&s_UARTHandle,generic_buffer,1, HAL_MAX_DELAY);
HAL_UART_Transmit(&s_UARTHandle,generic_buffer, sizeof(generic_buffer), HAL_MAX_DELAY);

}

But the code is not working, is there something missing in the configuration? I'm using the same code that worked in my STM32F407VG, changing the USART name and pins.




No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...