你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。
chrome
firefox
safari
ie8及以上
ST
意法半导体官网
STM32
中文官网
ST
全球论坛
登录/注册
首页
技术问答
话题
资源
创客秀
视频
标签
积分商城
每日签到
stmf429 usart1 进不了接收中断, 轮询可以接收
[复制链接]
liangyuejie
提问时间:2015-3-24 11:15 /
阅读主题, 点击返回1楼
赞
0
收藏
0
评论
19
分享
发布时间:2015-3-24 11:15
请先
登录
后回复
19个回答
liangyuejie
回答时间:2015-3-25 11:32:00
a0a.1 32b0c
回12楼: 不是没有复用模式,是没有复用时钟
赞
0
评论
回复
支持
反对
拼命三郎
回答时间:2015-3-25 12:45:35
a0a.1 32b0c
赞
0
评论
回复
支持
反对
拼命三郎
回答时间:2015-3-25 12:46:50
a0a.1 32b0c
赞
0
评论
回复
支持
反对
废鱼
回答时间:2015-3-25 14:54:57
a0a.1 32b0c
优先级不对吧,你改成0试试。这我得看一下M4内核手册。
赞
0
评论
回复
支持
反对
liangyuejie
回答时间:2015-3-25 16:44:11
a0a.1 32b0c
谢谢大家,同样的程序,因泡桐样例程序之后,工作正常了:
// NVIC configration
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
// USART configuation
USART_Config();
void USART_Config_USART1()
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
// Enable GPIO clock
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
// Enable USART clock
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
// Configure USART Tx as alternate function
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// Configure USART Rx as alternate function
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// Config AF pin
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);
// Initialize USART
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
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;
USART_Init(USART1, &USART_InitStructure);
// Enable USART
USART_Cmd(USART1, ENABLE);
#if defined(INNO_DEBUG)
USART1_SendDataStrings("USART1 enabled! \n");
#endif
// Initialize USART interrupt on NVIC
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0xF;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
#if defined(INNO_DEBUG)
USART1_SendDataStrings("USART1 NVIC enabled! \n");
#endif
// Enable USART interrupt
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
#if defined(INNO_DEBUG)
USART1_SendDataStrings("USART1 IT_RXNE enabled! \n");
#endif
//USART_ITConfig(USART1, USART_IT_TXE, ENABLE);
#if defined(INNO_DEBUG)
USART1_SendDataStrings("USART1 IT_TXE enabled! \n");
#endif
}
void USART_Config()
{
USART_Config_USART1();
#if defined(INNO_DEBUG)
USART1_SendDataStrings("USART1 configuration finished! \n");
#endif
#if defined(INNO_DEBUG)
USART1_SendDataStrings("USART all configuration finished! \n");
#endif
}
it.c
void USART1_IRQHandler(void)
{
uint16_t receiveData = 0;
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
{
receiveData = USART_ReceiveData(USART1);
USART1_SendDataCharacter(receiveData);
}
}
USART_GetITStatus && USART_ReceiveData
USART_GetFlagStatus && USART_ReceiveData
软件流清标志位都可
赞
0
评论
回复
支持
反对
1
2
/ 2 页
所属标签
相似问题
关于
意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
微信公众号
手机版
快速回复
返回顶部
返回列表
// NVIC configration
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
// USART configuation
USART_Config();
void USART_Config_USART1()
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
// Enable GPIO clock
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
// Enable USART clock
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
// Configure USART Tx as alternate function
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// Configure USART Rx as alternate function
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// Config AF pin
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);
// Initialize USART
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
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;
USART_Init(USART1, &USART_InitStructure);
// Enable USART
USART_Cmd(USART1, ENABLE);
#if defined(INNO_DEBUG)
USART1_SendDataStrings("USART1 enabled! \n");
#endif
// Initialize USART interrupt on NVIC
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0xF;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
#if defined(INNO_DEBUG)
USART1_SendDataStrings("USART1 NVIC enabled! \n");
#endif
// Enable USART interrupt
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
#if defined(INNO_DEBUG)
USART1_SendDataStrings("USART1 IT_RXNE enabled! \n");
#endif
//USART_ITConfig(USART1, USART_IT_TXE, ENABLE);
#if defined(INNO_DEBUG)
USART1_SendDataStrings("USART1 IT_TXE enabled! \n");
#endif
}
void USART_Config()
{
USART_Config_USART1();
#if defined(INNO_DEBUG)
USART1_SendDataStrings("USART1 configuration finished! \n");
#endif
#if defined(INNO_DEBUG)
USART1_SendDataStrings("USART all configuration finished! \n");
#endif
}
it.c
void USART1_IRQHandler(void)
{
uint16_t receiveData = 0;
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
{
receiveData = USART_ReceiveData(USART1);
USART1_SendDataCharacter(receiveData);
}
}
USART_GetITStatus && USART_ReceiveData
USART_GetFlagStatus && USART_ReceiveData
软件流清标志位都可