打印
[STM32F1]

奇怪的现象求解!

[复制链接]
943|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
jd9945|  楼主 | 2015-7-30 17:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
IO, pi, GPIO, gp, ni

void Init_All_Periph(void)
{
        GPIO_InitTypeDef GPIO_InitStructure;
        NVIC_InitTypeDef NVIC_InitStructure;
        RCC_Configuration();
        #if  1
        GPIO_Configuration();
        NVIC_Configuration();
        #else
        /* Configure CAN pin: RX */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
        GPIO_Init(GPIOA, &GPIO_InitStructure);
        /* Configure CAN pin: TX */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
        GPIO_InitStructure.GPIO_Mode =  GPIO_Mode_AF_PP;
        GPIO_Init(GPIOA, &GPIO_InitStructure);
       
        NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

//  /* enabling interrupt */
        NVIC_InitStructure.NVIC_IRQChannel=USB_LP_CAN1_RX0_IRQn;// USB_LP_CAN_RX0_IRQChannel;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
        #endif

}


void GPIO_Configuration(void)
{
        GPIO_InitTypeDef GPIO_InitStructure;
        /* Configure CAN pin: RX */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
        GPIO_Init(GPIOA, &GPIO_InitStructure);
        /* Configure CAN pin: TX */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
        GPIO_InitStructure.GPIO_Mode =  GPIO_Mode_AF_PP;
        GPIO_Init(GPIOA, &GPIO_InitStructure);


}

//系统中断管理
void NVIC_Configuration(void)
{
        NVIC_InitTypeDef NVIC_InitStructure;
        GPIO_InitTypeDef GPIO_InitStructure;

        /* Configure the NVIC Preemption Priority Bits */
        NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

#if  0
#ifdef  VECT_TAB_RAM
        /* Set the Vector Table base location at 0x20000000 */
        NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else  /* VECT_TAB_FLASH  */
        /* Set the Vector Table base location at 0x08000000 */
        NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif
#endif       

//  /* enabling interrupt */
        NVIC_InitStructure.NVIC_IRQChannel=USB_LP_CAN1_RX0_IRQn;// USB_LP_CAN_RX0_IRQChannel;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);

}
把上面的函数Init_All_Periph中#if   1时, cantx可以正常输出电平, 改成#if  0后, cantx一直输出低电平, 其他的程序都没有变的情况下.



沙发
mmuuss586| | 2015-7-30 20:23 | 只看该作者
没看出什么区别;
void GPIO_Configuration(void)
这个函数里,就多了一个IF;
但这段程序是不影响的;

猜不出来啥问题了;

使用特权

评论回复
板凳
jd9945|  楼主 | 2015-7-31 08:29 | 只看该作者
那个是被注释掉的!

使用特权

评论回复
地板
amanda_s| | 2015-7-31 17:13 | 只看该作者
程序看起来是一样的呀。
程序跑起来,看看实际寄存器配置的情况。

使用特权

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

本版积分规则

26

主题

84

帖子

0

粉丝