找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2251|回复: 0
收起左侧

Using USART1 on the STM32F4Discovery

[复制链接]
ID:104126 发表于 2016-1-23 02:48 | 显示全部楼层 |阅读模式
While it was very good of ST to make the fantastically inexpensiveand versatile STM32F4Discovery board, they have made things alittle difficult in the choice of peripherals in places.

I use the board as a test bed for my micromouse code. All themicromouse peripherals are wired up to some perfboard that alsoholds the STM32F4Discovery. The drivers for everything on the mousecan easily be tested and I can experiment with different userinterfaces, motor PWM schemes and sensor combinations. All withoutputting my mouse board at risk.

Generally, this works fine but, for compatibility with my STM32F103code, I chose to use USART1 as the main serial terminal on themouse. The STM32f4Discovery schematic shows that the default pinfor serial TX on this USART is PA9. That is connected to an LED anda 4.7uF capacitor (C49). The pin is used for the VBUS line on theUSB OTG port. The capacitor means that the pin is essentiallyincapable fo doing any useful serial speed at all.

Since I have no interest in using the USB OTG functions, I simplydesoldered the capacitor. Actually, I stood it up on one end sothat I could put it back if ever I had a change of heart.

A further look at the schematic shows that pin PC0 is used toenable the STMPS2141 power switch. This will place 5V on the PA9serial line whenever PC0 is set low. A zero Ohm resistor connectsPC0 to the enable line of this switch so I stood that on end aswell.

Finally, the LED (LD7) is lit when PA9 is high. However, the baseof the driver transistor is not held low so the LED does not turnoff reliably. There are pads available on the board to fit asuitable resistor as R57. I chose a 22k resistor so that 3V on PA9would be enough to turn on the LED but anything less than about 2Vwould not.

Now I get good serial data out of USART1 and I don’t have to worryabout 5V appearing on the line when PC0 is changed. As a bonus, Iget the LED (LD7 at the bottom of the board) telling me when thereis activity on the PA9 line. The TX line will idle high so the LEDis on most of the time.


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表