cancel
Showing results for 
Search instead for 
Did you mean: 

USART problem on STM32F415RG

matke2002
Associate II
Posted on January 15, 2016 at 16:04

Hi,

first to say that I'm beginner with STM32 programming, I study this uC entire month.

I'm using board based on this http://www.mikroe.com/mini/stm32/

and I have limited (or no) support from manufacturer.

I created Keil project with STM32CubeMX app, and attached everything in ser3.zip (excluded folder Drivers)

I noticed that UART4 and USART1 are initialized (only on UART4 I have DE-9 connector), and in while loop I call:  HAL_UART_Transmit_IT(&huart4, ''COM1\r\n'', 6);

but nothing arrives on my serial port (only first attempt return HAL_OK, other some error, didn't determined what exactly)

I compared mine project with this

https://github.com/fboris/STM32Cube_FW_F4/blob/master/Projects/STM324xG_EVAL/Examples/UART/UART_Hyperterminal_IT/Src/main.c

but couldn't find some differences.

Can someone check, did I missed something in STM32CubeMX, or something in main() ??

Some short notice about ports and devices attached on MINI-M4:

PC12,PC13,PA14  == LED

PC11,PC10  ==  UART4 Rx and Tx (with DE-9 connector)

PB7,PB6  ==  USART1 Rx and Tx (no output)

Tx

4 REPLIES 4
Posted on January 15, 2016 at 16:51

I have limited (or no) support from manufacturer.

It's pretty limited here too.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
matke2002
Associate II
Posted on January 15, 2016 at 22:57

I know that, but this is forum what use people who already work with this uC.

All I ask to someone see main function, and STM32CubeMX project I attached.

Maybe I made there some error.
piececakeof
Associate II
Posted on January 16, 2016 at 12:53

Hi Ivan. As i can remember MxCube make generates initialization function for interface(in your case - USART) controller - not for the gpios, - you need do it by yourself: configure the needed pins with alternate function selection, output mode, speed...etc. So i think you have silent pins because they are simpy not configured yet. Also check clock selection, and maybe you need enable clocking of usart manually. Btw - the error (when you check return value from rx\tx func) that you toke - can be referenced to this case(not conf. gpios)

matke2002
Associate II
Posted on January 18, 2016 at 13:23

It looks to me like it generated GPIOS

here's the code:

void HAL_UART_MspInit(UART_HandleTypeDef* huart)

{

  GPIO_InitTypeDef GPIO_InitStruct;

  if(huart->Instance==UART4)

  {

  /* USER CODE BEGIN UART4_MspInit 0 */

  /* USER CODE END UART4_MspInit 0 */

    /* Peripheral clock enable */

    __UART4_CLK_ENABLE();

 

    /**UART4 GPIO Configuration    

    PC10     ------> UART4_TX

    PC11     ------> UART4_RX

    */

    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_AF8_UART4;

    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

  /* USER CODE BEGIN UART4_MspInit 1 */

  /* USER CODE END UART4_MspInit 1 */

  }

  else if(huart->Instance==USART1)

  {

  /* USER CODE BEGIN USART1_MspInit 0 */

  /* USER CODE END USART1_MspInit 0 */

    /* Peripheral clock enable */

    __USART1_CLK_ENABLE();

 

    /**USART1 GPIO Configuration    

    PB6     ------> USART1_TX

    PB7     ------> USART1_RX

    */

    GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_PULLUP;

    GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;

    GPIO_InitStruct.Alternate = GPIO_AF7_USART1;

    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

  /* USER CODE BEGIN USART1_MspInit 1 */

  /* USER CODE END USART1_MspInit 1 */

  }

}

Anyway, I detected error codes:

after first ''successfull'' (but without output on putty)

HAL_UART_Transmit_IT returns HAL_BUSY

and

HAL_UART_GetState returns HAL_UART_STATE_BUSY_TX

Any idea?