你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

串口中断程序进入了总线错误中断???

[复制链接]
漂泊的雨林 提问时间:2015-5-12 20:46 /
先上程序
#include "stm32f10x.h"
#include <stdio.h>
#include "touwenjian.h"

extern uint8_t ch;
extern uint8_t flog;
int main(void)
{
        USART1_Init();
        nvic_Init();
        while(flog==1)
        {
                 USART_SendData(USART1, ch);
          while( USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET );
                flog=0;
        }
}


下面是中断程序
void USART1_IRQHandler(void)
{
        if(USART_GetITStatus(USART1,USART_IT_RXNE)!=RESET)
        {       
          ch=USART_ReceiveData(USART1);
                while(USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET){}
                flog=1;                
        }
}

配置程序
void nvic_Init(void)
{   
     NVIC_InitTypeDef NVIC_InitStructure;
     NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);

    NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;       
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02;  
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x03;               
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;                       
    NVIC_Init(&NVIC_InitStructure);       
}

void USART1_Init(void)
{
     GPIO_InitTypeDef GPIO_InitStructure;
     USART_InitTypeDef USART_InitStructure;
         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA , ENABLE);
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);        
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOA , &GPIO_InitStructure);

     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
    GPIO_Init(GPIOA , &GPIO_InitStructure);

        USART_InitStructure.USART_BaudRate = 115200;            
    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);
    USART_ITConfig(USART1,USART_IT_RXNE,ENABLE);
     USART_Cmd(USART1, ENABLE);  
}


问题是我硬件仿真的时候他进入了
void BusFault_Handler(void)
{
  /* Go to infinite loop when Bus Fault exception occurs */
  while (1)
  {
  }
}这个总线错误中断


额求帮助
收藏 评论1 发布时间:2015-5-12 20:46

举报

1个回答
废鱼 回答时间:2015-5-13 11:14:31
单步仿真一下,看看走到哪儿进入的这个中断。

所属标签

相似问题

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版