OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 6638|回复: 1

UART4配置不成功,怎么回事?

[复制链接]

64

主题

227

帖子

0

精华

高级会员

Rank: 4

积分
541
金钱
541
注册时间
2011-7-23
在线时间
13 小时
发表于 2012-12-10 14:26:16 | 显示全部楼层 |阅读模式
void UART4_Configuration(void)
{
    USART_InitTypeDef USART_InitStructure;
    USART_ClockInitTypeDef  USART_ClockInitStructure;
    USART_ClockInitStructure.USART_Clock    = USART_Clock_Disable;
    USART_ClockInitStructure.USART_CPOL     = USART_CPOL_Low;
    USART_ClockInitStructure.USART_CPHA     = USART_CPHA_2Edge;
    USART_ClockInitStructure.USART_LastBit  = USART_LastBit_Disable;
    /* Configure the USART1 synchronous paramters */
    USART_ClockInit(UART4, &USART_ClockInitStructure); 
    //波特率设置为115200
    USART_InitStructure.USART_BaudRate      = 115200;   //38400;
    //一帧数据的宽度设置为8bits
    USART_InitStructure.USART_WordLength    = USART_WordLength_8b;
    //在帧结尾传输1个停止位
    USART_InitStructure.USART_StopBits      = USART_StopBits_1;
    //奇偶失能模式,无奇偶校验
    USART_InitStructure.USART_Parity        = USART_Parity_No ;
    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 
    USART_InitStructure.USART_Mode          = USART_Mode_Rx |  USART_Mode_Tx;
    /* Configure USART2 basic and asynchronous paramters */
    USART_Init(UART4, &USART_InitStructure);  
    /*打开串口2的中断响应函数,接收中断*/
    USART_ITConfig(UART4, USART_IT_RXNE, ENABLE); 
    /*打开串口2*/  
    USART_Cmd(UART4, ENABLE);  
}


每次执行到USART_ClockInit(UART4, &USART_ClockInitStructure); 这条语句的时候,就跳到void assert_failed(uint8_t* file, uint32_t line)这句了,硬件错误吗?






正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2012-12-11 18:06:11 | 显示全部楼层
论坛有参考代码,不过貌似都是寄存器版本。
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复 支持 反对

使用道具 举报

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

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-7-19 08:19

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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