打印
[STM32F0]

STM32F091芯片USART3~USART8无法进入接收中断

[复制链接]
1665|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zhxingyu|  楼主 | 2018-11-5 22:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 zhxingyu 于 2018-11-6 08:46 编辑

static void RCC_Configuration(void)
{   
  /* Enable GPIO clock */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA|RCC_AHBPeriph_GPIOB|RCC_AHBPeriph_GPIOC|RCC_AHBPeriph_GPIOD|RCC_AHBPeriph_GPIOF, ENABLE);
  
  /* Enable 8xUSARTs Clock */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2|RCC_APB1Periph_USART3|RCC_APB1Periph_USART4|RCC_APB1Periph_USART5, ENABLE);  
  
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6|RCC_APB2Periph_USART7|RCC_APB2Periph_USART8|RCC_APB2Periph_USART1, ENABLE);
}
static void NVIC_Configuration(void)
{
  NVIC_InitTypeDef NVIC_InitStructure;
  
  /* USART1 IRQ Channel configuration */
  NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPriority = 0x01;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  
  /* USART2 IRQ Channel configuration */
  NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPriority = 0x01;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  
  /* USART3_8 IRQ Channel configuration */
  NVIC_InitStructure.NVIC_IRQChannel = USART3_8_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPriority = 0x01;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
}
/* USART3 Pins configuration  ***********************************************/  
  /* Connect pin to Periph */
  GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_4);
  GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_4);   
  
  /* Configure pins as AF pushpull */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOB, &GPIO_InitStructure);

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(USART3, &USART_InitStructure);
   
              /* Enable 8xUSARTs Receive interrupts */
              USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
   
              /* Enable the 8xUSARTs */
              USART_Cmd(USART3, ENABLE);

void USART3_8_IRQHandler(void)
{
if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET)
  {
          dumm = USART_ReceiveData(USART3);
         // if(Usart_RxSetp(UsartIndex,dumm) == 0)return;
          Usart_RxSetp(UsartIndex,dumm);
  }
}
请帮忙看看USART3无法进入接收中断,能正常发送。当有数据时即进入死循环函数:
void HardFault_Handler(void)
{
  /* Go to infinite loop when Hard Fault exception occurs */
  while (1)
  {
  }
}
沙发
捉虫天师| | 2018-11-5 23:16 | 只看该作者
没用过这个,能用图形化配置吗

使用特权

评论回复
板凳
zhxingyu|  楼主 | 2018-11-6 08:43 | 只看该作者
USART1和USART2能正常接收,USART3~USART8都不行,收到数据就进入死循环。

使用特权

评论回复
地板
guanjiaer| | 2018-11-7 12:10 | 只看该作者
打断点 看看死在哪个语句上了呀

使用特权

评论回复
5
renzheshengui| | 2018-11-7 12:59 | 只看该作者
中断函数里边卡死的?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

69

主题

309

帖子

3

粉丝