|
本帖最后由 ul4 于 2014-11-18 00:15 编辑
STM32F042G6有32KB flash, 6KB ram, QFN-28(4x4mm)
可以用内部高精度48MHz RC(HSI48)直接驱动USB,从此不用外部晶振!
个人认为十分适合拿来做USB应用
但是因为low pin count的缘故
ST在20及28pin的STM32F042中将PA11/12与PA9/10这两组接脚做了复用
Pin pair PA11/12 can be remapped instead of pin pair PA9/10 using the SYSCFG_CFGR1 register
因为USB接脚对应至PA11/12,所以我们使用前必须先做切换
顺带一提启用CAN也要切换IO
由于ST目前还没有针对STM32F042提供例程
所以要从STM32F072的例程来修改:
基于ST例程STM32F0x2_USB-FS-Device_Lib V1.0.0的Virtual_COM_Port
添加了两行
app.c
- int main(void)
- {
- /*!< At this stage the microcontroller clock setting is already configured,
- this is done through SystemInit() function which is called from startup
- file (startup_stm32f072.s) before to branch to application main.
- To reconfigure the default setting of SystemInit() function, refer to
- system_stm32f0xx.c file
- */
-
- /*The SYSCFG registers can be accessed only when the SYSCFG
- interface APB clock is enabled.
- To enable SYSCFG APB clock use:
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE).*/
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
- /*!< PA11 and PA12 remapping bit for small packages (28 and 20 pins).
- 0: No remap (pin pair PA9/10 mapped on the pins)
- 1: Remap (pin pair PA11/12 mapped instead of PA9/10) */
- SYSCFG->CFGR1 |= SYSCFG_CFGR1_PA11_PA12_RMP;
- /* The Application layer has only to call USBD_Init to
- initialize the USB low level driver, the USB device library, the USB clock
- ,pins and interrupt service routine (BSP) to start the Library*/
- USBD_Init(&USB_Device_dev,
- &USR_desc,
- &USBD_CDC_cb,
- &USR_cb);
-
- while (1)
- {
- }
- }
复制代码
最后别忘了去stm32072b_eval.c及stm32072b_eval.h修改USART的接脚定义
STM32F042G6没有port D! |
阿莫论坛20周年了!感谢大家的支持与爱护!!
月入3000的是反美的。收入3万是亲美的。收入30万是移民美国的。收入300万是取得绿卡后回国,教唆那些3000来反美的!
|