Wednesday, November 28, 2012

STM32F3-Discovery Usart with printf

Hi,

The next step after setting up the Development Environment for STM32F3-Discovery was to communicate with computer via serial port.
I have added usart support to my board using USART2 module, which had TX connected to PA2 pin and RX to PA3 pin(both with alternate function set to 7).

The next step was to connect the pins to PC serial port. I have used a MAX3232 module(note that you need a chip with 3.3V support).

After using printf function I have noticed that linker asks for some functions like _write which are used internally. I have added a file newlib_subs.c to implement these function.

You can download the example project from here.
The settings for usart communication are:
baudrate: 115200
parity: none
data bits: 8
stop bits: 1
flow control: none

If you want to use interrupts to read from USART you can use the code from here.

You can check my project via svn from my repository using:
svn checkout http://andrei-development.googlecode.com/svn/branches/dev/stm32f3-discovery


15 comments:

  1. Hi Andrei, your blog posts have been really helpful -- I set up a development environment on windows using your makefiles and eclipse with some pretty minimal modifications. Can you put up a small example of how to do USART reads on the stm32f3, either with polling or interrupts?

    ReplyDelete
    Replies
    1. Hi cornmander!

      I have updated the post and added an example to the svn repository.

      Regards,
      Andrei

      Delete
  2. Hi Andrei! Hi also found your blog very helpful to set up my tool-chain. I have one of these boards too and I would like to ask if you already saw some VCP or CDC examples for USB. ST doesn't have any one for this board, or at least I can't found it... Thank you very much!

    ReplyDelete
    Replies
    1. Hi!
      First of all, you should copy the usb driver folder(STM32_USB-FS-Device_Driver) from ST to the Libraries folder and then modify the Makefile:
      add $(wildcard Libraries/STM32_USB-FS-Device_Driver/src/*.c) to LIB_SRCS variable and also add -ILibraries/STM32_USB-FS-Device_Driver/inc/ to INCLUDES variable.
      you can inspire from the following link, to port CDC demo to STM32F3:
      https://www.das-labor.org/trac/browser/microcontroller/src-stm32f4xx/serialUSB

      Good luck!

      Andrei

      Delete
    2. Hi! Thanks for the replay! I will give it a try... If I came with a working solution I will give you an update.

      Delete
  3. Any luck with USB CDC on the STM32F3?

    ReplyDelete
  4. https://docs.google.com/file/d/0B7OY5pub_GfIN3EyMFlEZWhGMUk/edit

    ReplyDelete
  5. Hy Patrick,
    i am new user,
    how can i do t have the key.while the projektpage ist locked.
    i need to two example, to see how i can write a Usartcode zu commmunicate with my computer.

    than for your reply

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Hy Andrei,
    i am new user, please Patrick i am sorry for the mistake.
    the comment was been asssigned to Andrei.
    how can i do t have the key.while the projektpage ist locked.
    i need to two example, to see how i can write a Usartcode zu commmunicate with my computer.

    than for your reply

    ReplyDelete
  8. Hello Andrei,
    Can i have your authentification to download your project. This is a svn repository and it says to me that i must enter an ID and password for the project.

    Thank for your reply

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete