OpenEdv-开源电子网

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

STM32F030CCT6有6个串口,可是中断向量表只有串口1和串口2,串口3到6该怎么接收

[复制链接]

5

主题

28

帖子

0

精华

初级会员

Rank: 2

积分
141
金钱
141
注册时间
2016-7-25
在线时间
32 小时
发表于 2017-11-28 21:05:13 | 显示全部楼层 |阅读模式
10金钱
最近项目需要用上了stm32f0系列的030cct6,有六个串口,调试配置六路串口的时候总是发现进入异常中断,然后一个个排除,发现仅有串口1和串口2进入接收中断并清除中断标志,串口3到串口6都无法进入接收中断清除中断标志。其后追到中断向量表,惊奇的发现竟然没有串口3到串口6的中断函数,百思不得其解,求各路大神帮帮忙
部分代码如下
void uart_init(void)
{
        GPIO_InitTypeDef GPIO_InitStructure;
        USART_InitTypeDef USART_InitStructure;
       
        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA|RCC_AHBPeriph_GPIOB, ENABLE);
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1|RCC_APB2Periph_USART6,ENABLE);
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2|RCC_APB1Periph_USART3|RCC_APB1Periph_USART4|RCC_APB1Periph_USART5,ENABLE);
       
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource9,GPIO_AF_1);//引脚复用配置
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource10,GPIO_AF_1);//引脚复用配置.....1
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource0,GPIO_AF_4);//引脚复用配置
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource1,GPIO_AF_4);//引脚复用配置.....4
        GPIO_PinAFConfig(GPIOB, GPIO_PinSource10,GPIO_AF_4);//引脚复用配置
        GPIO_PinAFConfig(GPIOB, GPIO_PinSource11,GPIO_AF_4);//引脚复用配置.....3
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource2,GPIO_AF_1);//引脚复用配置
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource3,GPIO_AF_1);//引脚复用配置.....2
        GPIO_PinAFConfig(GPIOB, GPIO_PinSource3,GPIO_AF_4);//引脚复用配置
        GPIO_PinAFConfig(GPIOB, GPIO_PinSource4,GPIO_AF_4);//引脚复用配置.....5
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource4,GPIO_AF_5);//引脚复用配置
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource5,GPIO_AF_5);//引脚复用配置.....6
       
        //USART1_TX   GPIOA.9
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//输入GPIO_Mode_IN、输出GPIO_Mode_OUT、GPIO_Mode_AF复用功能、GPIO_Mode_AN模拟功能
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推完输出GPIO_OType_PP、漏极输出GPIO_OType_OD
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  //USART1_RX          GPIOB.10
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//输入GPIO_Mode_IN、输出GPIO_Mode_OUT、GPIO_Mode_AF复用功能、GPIO_Mode_AN模拟功能
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;//GPIO_PuPd上下拉: 浮空GPIO_PuPd_NOPULL、上拉GPIO_PuPd_UP、下拉GPIO_PuPd_DOWN
  GPIO_Init(GPIOA, &GPIO_InitStructure);
       
        //USART4_TX   GPIOA.0
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//输入GPIO_Mode_IN、输出GPIO_Mode_OUT、GPIO_Mode_AF复用功能、GPIO_Mode_AN模拟功能
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推完输出GPIO_OType_PP、漏极输出GPIO_OType_OD
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  //USART4_RX          GPIOB.1
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//输入GPIO_Mode_IN、输出GPIO_Mode_OUT、GPIO_Mode_AF复用功能、GPIO_Mode_AN模拟功能
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;//GPIO_PuPd上下拉: 浮空GPIO_PuPd_NOPULL、上拉GPIO_PuPd_UP、下拉GPIO_PuPd_DOWN
  GPIO_Init(GPIOA, &GPIO_InitStructure);
       
        //USART3_TX   GPIOB.10
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//输入GPIO_Mode_IN、输出GPIO_Mode_OUT、GPIO_Mode_AF复用功能、GPIO_Mode_AN模拟功能
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推完输出GPIO_OType_PP、漏极输出GPIO_OType_OD
  GPIO_Init(GPIOB, &GPIO_InitStructure);

  //USART3_RX          GPIOB.11
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//输入GPIO_Mode_IN、输出GPIO_Mode_OUT、GPIO_Mode_AF复用功能、GPIO_Mode_AN模拟功能
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;//GPIO_PuPd上下拉: 浮空GPIO_PuPd_NOPULL、上拉GPIO_PuPd_UP、下拉GPIO_PuPd_DOWN
  GPIO_Init(GPIOB, &GPIO_InitStructure);
       
        //USART2_TX   GPIOA.2
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//输入GPIO_Mode_IN、输出GPIO_Mode_OUT、GPIO_Mode_AF复用功能、GPIO_Mode_AN模拟功能
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推完输出GPIO_OType_PP、漏极输出GPIO_OType_OD
        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;//GPIO_PuPd上下拉: 浮空GPIO_PuPd_NOPULL、上拉GPIO_PuPd_UP、下拉GPIO_PuPd_DOWN
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  //USART2_RX          GPIOA.3
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//输入GPIO_Mode_IN、输出GPIO_Mode_OUT、GPIO_Mode_AF复用功能、GPIO_Mode_AN模拟功能
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;//GPIO_PuPd上下拉: 浮空GPIO_PuPd_NOPULL、上拉GPIO_PuPd_UP、下拉GPIO_PuPd_DOWN
  GPIO_Init(GPIOA, &GPIO_InitStructure);
       
        //USART5_TX   GPIOB.3
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//输入GPIO_Mode_IN、输出GPIO_Mode_OUT、GPIO_Mode_AF复用功能、GPIO_Mode_AN模拟功能
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推完输出GPIO_OType_PP、漏极输出GPIO_OType_OD
        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;//GPIO_PuPd上下拉: 浮空GPIO_PuPd_NOPULL、上拉GPIO_PuPd_UP、下拉GPIO_PuPd_DOWN
  GPIO_Init(GPIOB, &GPIO_InitStructure);

  //USART5_RX          GPIOB.4
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//输入GPIO_Mode_IN、输出GPIO_Mode_OUT、GPIO_Mode_AF复用功能、GPIO_Mode_AN模拟功能
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;//GPIO_PuPd上下拉: 浮空GPIO_PuPd_NOPULL、上拉GPIO_PuPd_UP、下拉GPIO_PuPd_DOWN
  GPIO_Init(GPIOB, &GPIO_InitStructure);
       
        //USART6_TX   GPIOA.4
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//输入GPIO_Mode_IN、输出GPIO_Mode_OUT、GPIO_Mode_AF复用功能、GPIO_Mode_AN模拟功能
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推完输出GPIO_OType_PP、漏极输出GPIO_OType_OD
        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;//GPIO_PuPd上下拉: 浮空GPIO_PuPd_NOPULL、上拉GPIO_PuPd_UP、下拉GPIO_PuPd_DOWN
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  //USART6_RX          GPIOA.5
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//输入GPIO_Mode_IN、输出GPIO_Mode_OUT、GPIO_Mode_AF复用功能、GPIO_Mode_AN模拟功能
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;//GPIO_PuPd上下拉: 浮空GPIO_PuPd_NOPULL、上拉GPIO_PuPd_UP、下拉GPIO_PuPd_DOWN
  GPIO_Init(GPIOA, &GPIO_InitStructure);
       
        USART_InitStructure.USART_BaudRate = 115200;//串口波特率
        USART_InitStructure.USART_WordLength = USART_WordLength_8b;//字长为8位数据格式
        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_InitStructure.USART_BaudRate = 115200;//串口波特率
        USART_InitStructure.USART_WordLength = USART_WordLength_8b;//字长为8位数据格式
        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(USART4, &USART_InitStructure);
       
        USART_InitStructure.USART_BaudRate = 115200;//串口波特率
        USART_InitStructure.USART_WordLength = USART_WordLength_8b;//字长为8位数据格式
        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);
       
        USART_InitStructure.USART_BaudRate = 115200;//串口波特率
        USART_InitStructure.USART_WordLength = USART_WordLength_8b;//字长为8位数据格式
        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(USART2, &USART_InitStructure);
       
        USART_InitStructure.USART_BaudRate = 115200;//串口波特率
        USART_InitStructure.USART_WordLength = USART_WordLength_8b;//字长为8位数据格式
        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(USART5, &USART_InitStructure);
       
        USART_InitStructure.USART_BaudRate = 115200;//串口波特率
        USART_InitStructure.USART_WordLength = USART_WordLength_8b;//字长为8位数据格式
        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(USART6, &USART_InitStructure);
       
        USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);//开启串口接受中断
        USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);//开启串口接受中断
        USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);//开启串口接受中断
        USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);//开启串口接受中断
        USART_ITConfig(USART5, USART_IT_RXNE, ENABLE);//开启串口接受中断
        USART_ITConfig(USART6, USART_IT_RXNE, ENABLE);//开启串口接受中断
       
        USART_Cmd(USART1, ENABLE);
        USART_Cmd(USART4, ENABLE);
        USART_Cmd(USART3, ENABLE);
        USART_Cmd(USART2, ENABLE);
        USART_Cmd(USART5, ENABLE);
        USART_Cmd(USART6, ENABLE);
       
        //NVIC----TIM.c
}


void Nvic_Init(void) //中断优先级设置
{
        NVIC_InitTypeDef NVIC_InitStructure;
       
        /*******************Tim3中断优先级设定**************************系统**/
        NVIC_InitStructure.NVIC_IRQChannel=TIM3_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPriority = 3;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
       
        /*******************USART1中断优先级设定***********************SENSOR**/
        NVIC_InitStructure.NVIC_IRQChannel=USART1_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
       
        /*******************USART2中断优先级设定***********************SENSOR**/
        NVIC_InitStructure.NVIC_IRQChannel=USART2_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
       
        /*******************USART3中断优先级设定**************************UWB**/
        NVIC_InitStructure.NVIC_IRQChannel=USART3_6_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPriority = 2;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
}


void USART1_IRQHandler (void)
{
        uint16_t temp;
        if(USART_GetITStatus(USART1,USART_IT_RXNE)!= RESET)   //Receive Data register not empty interrupt.
        {
                USART_ClearITPendingBit(USART1,USART_IT_RXNE);
                temp = USART_ReceiveData(USART1);   
                //USART_SendData(USART1,temp);
        }
}

void USART2_IRQHandler (void)
{
        uint16_t temp;
        if(USART_GetITStatus(USART2,USART_IT_RXNE)!= RESET)   //Receive Data register not empty interrupt.
        {
                USART_ClearITPendingBit(USART2,USART_IT_RXNE);
                temp = USART_ReceiveData(USART2);   
                //USART_SendData(USART2,temp);
        }
}

void USART3_IRQHandler (void)
{
        uint16_t temp;
        if(USART_GetITStatus(USART3,USART_IT_RXNE)!= RESET)   //Receive Data register not empty interrupt.
        {
                USART_ClearITPendingBit(USART3,USART_IT_RXNE);
                temp = USART_ReceiveData(USART3);   
                //USART_SendData(USART3,temp);
        }
}
void USART4_IRQHandler (void)
{
        uint16_t temp;
        if(USART_GetITStatus(USART4,USART_IT_RXNE)!= RESET)   //Receive Data register not empty interrupt.
        {
                USART_ClearITPendingBit(USART4,USART_IT_RXNE);
                temp = USART_ReceiveData(USART4);   
                //USART_SendData(USART4,temp);
        }
}
void USART5_IRQHandler (void)
{
        uint16_t temp;
        if(USART_GetITStatus(USART5,USART_IT_RXNE)!= RESET)   //Receive Data register not empty interrupt.
        {
                USART_ClearITPendingBit(USART5,USART_IT_RXNE);
                temp = USART_ReceiveData(USART5);   
                //USART_SendData(USART5,temp);
        }
}
void USART6_IRQHandler (void)
{
        uint16_t temp;
        if(USART_GetITStatus(USART6,USART_IT_RXNE)!= RESET)   //Receive Data register not empty interrupt.
        {
                USART_ClearITPendingBit(USART6,USART_IT_RXNE);
                temp = USART_ReceiveData(USART6);   
                //USART_SendData(USART6,temp);
        }
}




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

使用道具 举报

5

主题

28

帖子

0

精华

初级会员

Rank: 2

积分
141
金钱
141
注册时间
2016-7-25
在线时间
32 小时
 楼主| 发表于 2017-11-28 21:06:13 | 显示全部楼层
回复

使用道具 举报

5

主题

28

帖子

0

精华

初级会员

Rank: 2

积分
141
金钱
141
注册时间
2016-7-25
在线时间
32 小时
 楼主| 发表于 2017-11-28 21:07:07 | 显示全部楼层
__Vectors       DCD     __initial_sp                   ; Top of Stack
                DCD     Reset_Handler                  ; Reset Handler
                DCD     NMI_Handler                    ; NMI Handler
                DCD     HardFault_Handler              ; Hard Fault Handler
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     SVC_Handler                    ; SVCall Handler
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     PendSV_Handler                 ; PendSV Handler
                DCD     SysTick_Handler                ; SysTick Handler

                ; External Interrupts
                DCD     WWDG_IRQHandler                ; Window Watchdog
                DCD     PVD_IRQHandler                 ; PVD through EXTI Line detect
                DCD     RTC_IRQHandler                 ; RTC through EXTI Line
                DCD     FLASH_IRQHandler               ; FLASH
                DCD     RCC_IRQHandler                 ; RCC
                DCD     EXTI0_1_IRQHandler             ; EXTI Line 0 and 1
                DCD     EXTI2_3_IRQHandler             ; EXTI Line 2 and 3
                DCD     EXTI4_15_IRQHandler            ; EXTI Line 4 to 15
                DCD     TS_IRQHandler                  ; TS
                DCD     DMA1_Channel1_IRQHandler       ; DMA1 Channel 1
                DCD     DMA1_Channel2_3_IRQHandler     ; DMA1 Channel 2 and Channel 3
                DCD     DMA1_Channel4_5_IRQHandler     ; DMA1 Channel 4 and Channel 5
                DCD     ADC1_COMP_IRQHandler           ; ADC1, COMP1 and COMP2
                DCD     TIM1_BRK_UP_TRG_COM_IRQHandler ; TIM1 Break, Update, Trigger and Commutation
                DCD     TIM1_CC_IRQHandler             ; TIM1 Capture Compare
                DCD     TIM2_IRQHandler                ; TIM2
                DCD     TIM3_IRQHandler                ; TIM3
                DCD     TIM6_DAC_IRQHandler            ; TIM6 and DAC
                DCD     0                              ; Reserved
                DCD     TIM14_IRQHandler               ; TIM14
                DCD     TIM15_IRQHandler               ; TIM15
                DCD     TIM16_IRQHandler               ; TIM16
                DCD     TIM17_IRQHandler               ; TIM17
                DCD     I2C1_IRQHandler                ; I2C1
                DCD     I2C2_IRQHandler                ; I2C2
                DCD     SPI1_IRQHandler                ; SPI1
                DCD     SPI2_IRQHandler                ; SPI2
                DCD     USART1_IRQHandler              ; USART1
                DCD     USART2_IRQHandler              ; USART2
                DCD     0                              ; Reserved
                DCD     CEC_IRQHandler                 ; CEC
                DCD     0                              ; Reserved
               
__Vectors_End
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165516
金钱
165516
注册时间
2010-12-1
在线时间
2116 小时
发表于 2017-11-29 00:35:25 | 显示全部楼层
单独测试每个串口先,先别融在一起。
单独做。
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

1

主题

14

帖子

0

精华

初级会员

Rank: 2

积分
78
金钱
78
注册时间
2012-9-3
在线时间
8 小时
发表于 2018-8-3 20:34:20 | 显示全部楼层
本帖最后由 jinfahua 于 2018-8-3 20:35 编辑

请问楼主的问题是如何解决的?我找到STM32F030RC的USART3,4,5,6共用一个中断,中断号是29,但不知道进入中断后如何快速识别是哪个串口收到数据触发的中断,难道要对USART3-6的4个中断状态寄存器一个一个去测试?那就太花时间了。
回复

使用道具 举报

1

主题

14

帖子

0

精华

初级会员

Rank: 2

积分
78
金钱
78
注册时间
2012-9-3
在线时间
8 小时
发表于 2018-8-4 20:42:17 | 显示全部楼层
我用CUBE生成USART3-6的中断函数是这样的:
/**
* @brief This function handles USART3 to USART6 global interrupts.
*/
void USART3_6_IRQHandler(void)
{
  /* USER CODE BEGIN USART3_6_IRQn 0 */

  /* USER CODE END USART3_6_IRQn 0 */
  HAL_UART_IRQHandler(&huart3);
  HAL_UART_IRQHandler(&huart4);
  HAL_UART_IRQHandler(&huart5);
  HAL_UART_IRQHandler(&huart6);
  /* USER CODE BEGIN USART3_6_IRQn 1 */

  /* USER CODE END USART3_6_IRQn 1 */
}
不知道其中的huart3,4,5,6是什么意思?
回复

使用道具 举报

0

主题

1

帖子

0

精华

新手入门

积分
3
金钱
3
注册时间
2018-8-7
在线时间
1 小时
发表于 2018-8-7 20:05:03 | 显示全部楼层
你好 ,我是初学者,想问一下 STM32f030 不是只有2个USART可以用吗 ,6个串口是怎么解释
回复

使用道具 举报

13

主题

33

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
220
金钱
220
注册时间
2016-6-5
在线时间
66 小时
发表于 2018-8-29 09:16:02 | 显示全部楼层
请问楼主后来解决了吗
回复

使用道具 举报

56

主题

520

帖子

0

精华

高级会员

Rank: 4

积分
964
金钱
964
注册时间
2014-11-18
在线时间
160 小时
发表于 2018-8-31 14:52:38 | 显示全部楼层
小笼包 发表于 2017-11-28 21:07
__Vectors       DCD     __initial_sp                   ; Top of Stack
                DCD     Reset ...

我也不知道,不过原子哥的板子我之前吃过一个亏。
串口123 是USART     串口4 5 UART  这个你注意一下。
自己选择的路,成家前走完。
回复

使用道具 举报

1

主题

14

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2019-3-6
在线时间
11 小时
发表于 2019-3-6 19:04:04 | 显示全部楼层
Have you solved this issue me to facing the same problem coud you help to solve this
回复

使用道具 举报

3

主题

1907

帖子

0

精华

论坛元老

Rank: 8Rank: 8

积分
4106
金钱
4106
注册时间
2018-8-14
在线时间
696 小时
发表于 2019-3-6 19:15:38 | 显示全部楼层
本帖最后由 edmund1234 于 2019-3-6 19:18 编辑

不知道你的向量表从何而来的


Capture.PNG
回复

使用道具 举报

1

主题

14

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2019-3-6
在线时间
11 小时
发表于 2019-3-6 20:37:12 | 显示全部楼层
本帖最后由 Akash 于 2019-3-6 20:43 编辑
Edmund1234 Posted at 2019-3-6 19:15 I
don't know where your vector table comes from.

I don't know where to find the vector table but interrupt number is 29. I am new to stm

In my project i am using 5 usart in stm32f030cc but while transmitting data only two USART (USART 1 & USART2 ) are working USART 3, 4,5,6 is not working.

could you give me a sample code to send and receive data through usart1,2, 3,4,5 using interrupt
回复

使用道具 举报

3

主题

1907

帖子

0

精华

论坛元老

Rank: 8Rank: 8

积分
4106
金钱
4106
注册时间
2018-8-14
在线时间
696 小时
发表于 2019-3-6 20:59:01 | 显示全部楼层
Akash 发表于 2019-3-6 20:37
I don't know where to find the vector table but interrupt number is 29. I am new to stm

In my p ...

Download the doc。“RM0360”From ST WebSite。
what do u means not working?
M0 series, I haven't used any but usart1&2
回复

使用道具 举报

1

主题

14

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2019-3-6
在线时间
11 小时
发表于 2019-3-7 11:52:02 | 显示全部楼层
edmund1234 发表于 2019-3-6 20:59
Download the doc。“RM0360”From ST WebSite。
what do u means not working?
M0 series, I haven't ...

Thank you for sharing the doc

not working means there is no data transmitting or receiving through usart 3,4,5 and 6

i don't know how to use shared IRQ
回复

使用道具 举报

3

主题

1907

帖子

0

精华

论坛元老

Rank: 8Rank: 8

积分
4106
金钱
4106
注册时间
2018-8-14
在线时间
696 小时
发表于 2019-3-7 14:16:26 | 显示全部楼层
Akash 发表于 2019-3-7 11:52
Thank you for sharing the doc

not working means there is no data transmitting or receiving thro ...

if you have the problem to data transmition, I belive that the cause of problem is usart register setting, or peripherals clock not enable
回复

使用道具 举报

1

主题

14

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2019-3-6
在线时间
11 小时
发表于 2019-3-7 20:29:04 | 显示全部楼层
本帖最后由 Akash 于 2019-3-7 20:33 编辑
edmund1234 发表于 2019-3-7 14:16
if you have the problem to data transmition, I belive that the cause of problem is usart register  ...

i have configures properly and also the peripherals clock but still not working

Below i have attached the my program configuration

i have configures properly and also the peripherals clock but still not working

Below i have attached the my program configuration

[mw_shl_code=c,true]#include "main.h"

Void USART_Configuration(void);
Void USART1_Configuration(void);
Void USART2_Configuration(void);
Void USART3_Configuration(void);
Void USART4_Configuration(void);
Void USART5_Configuration(void);

USART1_Configuration void (void)
{
                        USART_InitTypeDef USART_InitStructure;
                        GPIO_InitTypeDef GPIO_InitStructure;
                        NVIC_InitTypeDef NVIC_InitStructure;
        
               
                        RCC_AHBPeriphClockCmd (RCC_AHBPeriph_GPIOA, the ENABLE);
                        RCC_APB2PeriphClockCmd (RCC_APB2Periph_USART1, the ENABLE);
        
                        GPIO_PinAFConfig (with GPIOA, GPIO_PinSource9, GPIO_AF_1);
                        GPIO_PinAFConfig (with GPIOA, GPIO_PinSource10, GPIO_AF_1);
        
                        / * The Configure the USART1 pins: the Rx and the Tx ---------------------------- * /
        
                        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
                        GPIO_InitStructure.GPIO_Speed GPIO_Speed_50MHz =;
                        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
                        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
                        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
                        GPIO_Init (with GPIOA, & GPIO_InitStructure);
        
                        / * * the Enable the USART1 the IRQ /
        
                        NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
                        NVIC_InitStructure.NVIC_IRQChannelPriority = 0;
                        NVIC_InitStructure .NVIC_IRQChannelCmd = ENABLE;
                        NVIC_Init(&NVIC_InitStructure);
                        
                        USART_InitStructure.USART_BaudRate = 9600;
                        = USART_WordLength_8b USART_InitStructure.USART_WordLength;
                        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 (the USART1, & USART_InitStructure);
                        USART_Cmd (the USART1, the ENABLE);
                        USART_ITConfig (the USART1, USART_IT_TXE, ENABLE);
                        USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
}
Void USART2_Configuration(void)
{
                        USART_InitTypeDef USART_InitStructure;
                        GPIO_InitTypeDef GPIO_InitStructure;
                        NVIC_InitTypeDef NVIC_InitStructure;
        
               
                        RCC_AHBPeriphClockCmd (RCC_AHBPeriph_GPIOA, the ENABLE);
                        RCC_APB1PeriphClockCmd (RCC_APB1Periph_USART2, the ENABLE);
        
                        GPIO_PinAFConfig (with GPIOA, GPIO_PinSource2, GPIO_AF_1);
                        GPIO_PinAFConfig (with GPIOA, GPIO_PinSource3, GPIO_AF_1);
        
                        / * the Configure USART2 is always pins: the Rx and the Tx --------- * ------------------- /
        
                        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;
                        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
                        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
                        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
                        GPIO_InitStructure .GPIO_PuPd = GPIO_PuPd_UP;
                        GPIO_Init(GPIOA, &GPIO_InitStructure);
        
                        /* Enable USART2 IRQ */
        
                        NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
                        = 0 NVIC_InitStructure.NVIC_IRQChannelPriority;
                        NVIC_InitStructure.NVIC_IRQChannelCmd = the ENABLE;
                        NVIC_Init (& NVIC_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 (USART2 is always, & USART_InitStructure);
                        USART_Cmd (USART2 is always, the ENABLE);
                        USART_ITConfig (USART2 is always, USART_IT_TXE, the ENABLE);
                        USART_ITConfig (USART2 is always, USART_IT_RXNE, the ENABLE);
}
Void USART3_Configuration (void)
{
                        USART_InitTypeDef USART_InitStructure;
                        GPIO_InitTypeDef GPIO_InitStructure;
                        NVIC_InitTypeDef NVIC_InitStructure;
        
               
                        RCC_AHBPeriphClockCmd (RCC_AHBPeriph_GPIOB, the ENABLE);
                        RCC_APB1PeriphClockCmd (RCC_APB1Periph_USART3, the ENABLE);
        
                        GPIO_PinAFConfig (GPIOB, GPIO_PinSource10, GPIO_AF_4);
                        GPIO_PinAFConfig (GPIOB, GPIO_PinSource11, GPIO_AF_4);
        
                        / * the Configure USART3 pins: Rx and Tx ----------------------------*/
        
                        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
                        GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_50MHz;
                        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
                        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
                        = GPIO_PuPd_UP GPIO_InitStructure.GPIO_PuPd;
                        GPIO_Init (GPIOB, & GPIO_InitStructure);
        
                        / * * the Enable USART3 the IRQ /
        
                        NVIC_InitStructure.NVIC_IRQChannel = USART3_6_IRQn;
                        NVIC_InitStructure.NVIC_IRQChannelPriority = 0;
                        NVIC_InitStructure.NVIC_IRQChannelCmd = the ENABLE;
                        NVIC_Init (& NVIC_InitStructure);
                        
                        USART_InitStructure.USART_BaudRate = 115200;
                        USART_InitStructure = USART_WordLength_8b .USART_WordLength;
                        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);
                        USART_Cmd (USART3, the ENABLE);
                                USART_ClearFlag (USART3, USART_FLAG_TC);
                        USART_ITConfig (USART3, USART_IT_TXE, the ENABLE);
                        USART_ITConfig (USART3, USART_IT_RXNE, the ENABLE);
}
Void USART4_Configuration (void)
{
                        USART_InitTypeDef USART_InitStructure;
                        GPIO_InitTypeDef GPIO_InitStructure;
                        NVIC_InitTypeDef NVIC_InitStructure;
        
               
                        RCC_AHBPeriphClockCmd (RCC_AHBPeriph_GPIOA, the ENABLE);
                        RCC_APB1PeriphClockCmd (RCC_APB1Periph_USART4, the ENABLE);
        
                        GPIO_PinAFConfig (with GPIOA, GPIO_PinSource0, GPIO_AF_0);
                        GPIO_PinAFConfig (with GPIOA, GPIO_PinSource1, GPIO_AF_0);
        
                        / * The Configure USART4 pins: the Rx and the Tx ---------------------------- * /
        
                        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
                        GPIO_InitStructure.GPIO_Speed GPIO_Speed_50MHz =;
                        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
                        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
                        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
                        GPIO_Init (with GPIOA, & GPIO_InitStructure);
        
                        / * * the Enable USART4 the IRQ /
        
                        NVIC_InitStructure.NVIC_IRQChannel = USART3_6_IRQn;
                        NVIC_InitStructure.NVIC_IRQChannelPriority = 0;
                        NVIC_InitStructure .NVIC_IRQChannelCmd = ENABLE;
                        NVIC_Init(&NVIC_InitStructure);
                        
                        USART_InitStructure.USART_BaudRate = 115200;
                        = USART_WordLength_8b USART_InitStructure.USART_WordLength;
                        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 (USART4, & USART_InitStructure);
                        USART_Cmd (USART4, the ENABLE);
                        USART_ITConfig (USART4, USART_IT_TXE, the ENABLE);
                        USART_ITConfig (USART4, USART_IT_RXNE, the ENABLE);
}
void USART5_Configuration (void)
{
                        USART_InitTypeDef USART_InitStructure;
                        GPIO_InitTypeDef GPIO_InitStructure;
                        NVIC_InitTypeDef NVIC_InitStructure;
        
               
                        RCC_AHBPeriphClockCmd (RCC_AHBPeriph_GPIOB, the ENABLE);
                        RCC_APB1PeriphClockCmd (RCC_APB1Periph_USART5, the ENABLE);
        
                        GPIO_PinAFConfig (GPIOB, GPIO_PinSource3, GPIO_AF_1);
                        GPIO_PinAFConfig (GPIOB, GPIO_PinSource4, GPIO_AF_1);
        
                        / * the Configure USART5 pins: the Rx and the Tx --------- * ------------------- /
        
                        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4;
                        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
                        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
                        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
                        GPIO_InitStructure .GPIO_PuPd = GPIO_PuPd_UP;
                        GPIO_Init(GPIOB, &GPIO_InitStructure);
        
                        /* Enable USART5 IRQ */
        
                        NVIC_InitStructure.NVIC_IRQChannel = USART3_6_IRQn;
                        = 0 NVIC_InitStructure.NVIC_IRQChannelPriority;
                        NVIC_InitStructure.NVIC_IRQChannelCmd = the ENABLE;
                        NVIC_Init (& NVIC_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 (USART5, & USART_InitStructure);
                        USART_Cmd (USART5, the ENABLE);
                        USART_ITConfig (USART5, USART_IT_TXE, the ENABLE);
                        USART_ITConfig (USART5, USART_IT_RXNE, the ENABLE);
}

Void USART_Configuration(void)
{
        USART1_Configuration();
        USART2_Configuration();
        USART3_Configuration();
        USART4_Configuration();
        USART5_Configuration();
        
}
int main(void)
{
       
        SystemInit();
        USART_Configuration();
        Delay_Init() ;

        while(1)
        {      
                USART_SendData(USART1, Data1);
                Delay_Ms(1000);
                USART_SendData(USART2, Data2);
                Delay_Ms(1000);
                USART_SendData(USART3, Data3);
                Delay_Ms(1000);
                USART_SendData(USART4, Data4);
                Delay_Ms(1000);
                USART_SendData(USART5, Data5);
                Delay_Ms(1000);
      }
}
[/mw_shl_code]


While transmitting data through usart 1 and 2 it is recving but not for USART 3,4 and 5
回复

使用道具 举报

2

主题

5

帖子

0

精华

新手上路

积分
37
金钱
37
注册时间
2019-3-7
在线时间
8 小时
发表于 2019-3-7 23:47:14 | 显示全部楼层
TIM图片20190307234229.png TIM图片20190307234416.png
我也是使用STM32F030CCT6怎么会没有中断呢?
你说的中断问题进不去是因为你需要编写中断函数,要不然堆栈是在中断!
回复

使用道具 举报

1

主题

14

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2019-3-6
在线时间
11 小时
发表于 2019-3-8 11:35:48 | 显示全部楼层
本帖最后由 Akash 于 2019-3-8 11:37 编辑

This is the IRq handler  written by me

there is no problem for usart 1 & 2 only problem is usart 3,4,5and 6


if u have any sample code to transmit data through usart 3,4,5and 6 plz share with me[mw_shl_code=c,true]void USART1_IRQHandler(void)
{
  uint8_t ch;

  if (USART_GetITStatus(USART1, USART_IT_RXNE))
                {
                        ch = USART1->RDR;
                        rxbuf1[rxptrh1++] = ch;

                }
  if (USART_GetITStatus(USART1, USART_IT_TXE)) {
    if (txlen1) {
      txlen1--;
      USART1->TDR = *txptr1++;
    }
    if (!txlen1) {
      USART_ITConfig(USART1, USART_IT_TXE, DISABLE);
    }
  }
}
void USART2_IRQHandler(void)
{
  uint8_t ch;

  if (USART_GetITStatus(USART2, USART_IT_RXNE)) {
    ch = USART2->RDR;
    rxbuf2[rxptrh2++] = ch;
   
  }
  if (USART_GetITStatus(USART2, USART_IT_TXE)) {
    if (txlen2) {
      txlen2--;
      USART2->TDR = *txptr2++;
    }
    if (!txlen2) {
      USART_ITConfig(USART2, USART_IT_TXE, DISABLE);
    }
  }
}
void USART3_6_IRQHandler(void)
{
        uint8_t ch;

        if (USART_GetITStatus(USART3, USART_IT_RXNE))
                {
                ch = USART3->RDR;
                rxbuf3[rxptrh3++] = ch;
         
        }
        if (USART_GetITStatus(USART3, USART_IT_TXE)) {
                if (txlen3) {
                        txlen3--;
                        USART3->TDR = *txptr3++;
                }
                if (!txlen3) {
                        USART_ITConfig(USART3, USART_IT_TXE, DISABLE);
                }
        }
        ///////////
        if (USART_GetITStatus(USART4, USART_IT_RXNE)) {
    ch = USART4->RDR;
    rxbuf4[rxptrh4++] = ch;
   
  }
  if (USART_GetITStatus(USART4, USART_IT_TXE)) {
    if (txlen4) {
      txlen4--;
      USART4->TDR = *txptr4++;
    }
    if (!txlen4) {
      USART_ITConfig(USART4, USART_IT_TXE, DISABLE);
    }
  }
        if (USART_GetITStatus(USART4, USART_IT_RXNE)) {
                ch = USART4->RDR;
                rxbuf4[rxptrh4++] = ch;
         
        }
        //////////////////
}[/mw_shl_code]
回复

使用道具 举报

0

主题

4

帖子

0

精华

新手入门

积分
12
金钱
12
注册时间
2019-4-17
在线时间
1 小时
发表于 2019-4-17 19:39:12 | 显示全部楼层
Akash 发表于 2019-3-8 11:35
This is the IRq handler  written by me

there is no problem for usart 1 & 2 only problem is usart ...

hi, i have the same problem, usart 1 &2 is ok but usart 3 4 5 6 not work.  How to solve     this problem?   (sorry, i am not good at english)
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165516
金钱
165516
注册时间
2010-12-1
在线时间
2116 小时
发表于 2019-4-18 01:56:57 | 显示全部楼层
QQQ662233 发表于 2019-4-17 19:39
hi, i have the same problem, usart 1 &2 is ok but usart 3 4 5 6 not work.  How to solve     this p ...

Witch  mcu do you use?
if you are using STM32F1,we have example for you.
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

0

主题

4

帖子

0

精华

新手入门

积分
12
金钱
12
注册时间
2019-4-17
在线时间
1 小时
发表于 2019-4-18 09:11:15 | 显示全部楼层
正点原子 发表于 2019-4-18 01:56
Witch  mcu do you use?
if you are using STM32F1,we have example for you.

STM32F030CC   
回复

使用道具 举报

0

主题

4

帖子

0

精华

新手入门

积分
12
金钱
12
注册时间
2019-4-17
在线时间
1 小时
发表于 2019-4-18 10:16:07 | 显示全部楼层
Akash 发表于 2019-3-7 20:29
i have configures properly and also the peripherals clock but still not working

Below i have a ...

maybe  your pin cfg error. [mw_shl_code=c,true]GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4;  below code is ok.
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF4_USART5;   
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);[/mw_shl_code]
alternate maybe error.
回复

使用道具 举报

1

主题

14

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2019-3-6
在线时间
11 小时
发表于 2019-4-22 14:27:16 | 显示全部楼层
正点原子 发表于 2019-4-18 01:56
Witch  mcu do you use?
if you are using STM32F1,we have example for you.

Do you have code for STM32F030CC

or you can share the code for STM32F1 more over it will be same only i can make the changes for stm32f030cc
回复

使用道具 举报

1

主题

14

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2019-3-6
在线时间
11 小时
发表于 2019-4-22 14:28:33 | 显示全部楼层
QQQ662233 发表于 2019-4-18 10:16
maybe  your pin cfg error. [mw_shl_code=c,true]GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4;  below ...

I have check all the AF pins also everything is fine
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165516
金钱
165516
注册时间
2010-12-1
在线时间
2116 小时
发表于 2019-4-23 02:08:45 | 显示全部楼层
Akash 发表于 2019-4-22 14:27
Do you have code for STM32F030CC

or you can share the code for STM32F1 more over it will be sa ...

yes,here is a 5 uart demo for STM32F103ZET6:http://www.openedv.com/forum.php?mod=viewthread&tid=289455
you can refer to this .
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

7

主题

143

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
434
金钱
434
注册时间
2017-8-21
在线时间
75 小时
发表于 2019-4-23 15:33:42 | 显示全部楼层
正点原子 发表于 2019-4-23 02:08
yes,here is a 5 uart demo for STM32F103ZET6:http://www.openedv.com/forum.php?mod=viewthread&tid= ...

原子哥,为啥论坛找不到STM32F030CCT6的资料,=-=我开始入行就是跟着探索者开发板学的,最近搞STM32F030CCT6的芯片,串口3用不了...跟上面楼主提问的一样,我虽然找到了中断函数,但是跑的时候就跑不起来
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165516
金钱
165516
注册时间
2010-12-1
在线时间
2116 小时
发表于 2019-4-24 01:58:16 | 显示全部楼层
路人曦 发表于 2019-4-23 15:33
原子哥,为啥论坛找不到STM32F030CCT6的资料,=-=我开始入行就是跟着探索者开发板学的,最近搞STM32F030C ...

因为我们没做这个开发板。。。
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

13

主题

33

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
220
金钱
220
注册时间
2016-6-5
在线时间
66 小时
发表于 2019-4-30 17:01:15 | 显示全部楼层

下面是我配置好的串口函数,测试了六个串口也都能进的去

* usart1: PA9, PA10
* usart2: PA2, PA3
* usart3: PB10, PB11
* usart4: PA0, PA1
* usart5: PB3, PB4
* usart6: PA4, PA5
*/
void uart_init(E_UartType eUartType, unsigned int uBaudRate)
{
        uint8_t uIRQChannel = USART1_IRQn;
        NVIC_InitTypeDef NVIC_InitStruct;
        GPIO_InitTypeDef GPIO_InitStructure;
        USART_InitTypeDef USART_InitStructure;
        GPIO_TypeDef *ptGpio = GPIOA;
        USART_TypeDef *ptUsart = USART1;

        if((unsigned char)eUartType < MAX_UART_COUNT){
                memset((void*)g_ptUartBufInfos[(unsigned char)eUartType], 0, sizeof(T_UartBuf));
        }
       
        switch(eUartType){
                case E_Uart1:
                        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,  ENABLE);
                        RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);

                        GPIO_PinAFConfig(GPIOA, GPIO_PinSource9,  GPIO_AF_1);
                        GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_1);
               
                        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
               
                        uIRQChannel = USART1_IRQn;
               
                        ptGpio  = GPIOA;
                        ptUsart = USART1;
                        break;
               
                case E_Uart2:
                        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
                        RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);

                        GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_1);
                        GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_1);
       
                        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;
               
                        uIRQChannel = USART2_IRQn;
               
                        ptGpio  = GPIOA;
                        ptUsart = USART2;
                        break;
//#ifdef STM32F030xC  
                case E_Uart3:
                        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
                        RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);

                        GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_4);
                        GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_4);
       
                        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
               
                        uIRQChannel = USART3_6_IRQn;
               
                        ptGpio  = GPIOB;
                        ptUsart = USART3;
                        break;
               
                case E_Uart4:
                        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,  ENABLE);
                        RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART4, ENABLE);

                        GPIO_PinAFConfig(GPIOA, GPIO_PinSource0, GPIO_AF_4);
                        GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_4);
               
                        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
               
                        uIRQChannel = USART3_6_IRQn;
               
                        ptGpio  = GPIOA;
                        ptUsart = USART4;
                        break;
               
                case E_Uart5:
                        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB,  ENABLE);
                        RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART5, ENABLE);

                        GPIO_PinAFConfig(GPIOB, GPIO_PinSource3, GPIO_AF_4);
                        GPIO_PinAFConfig(GPIOB, GPIO_PinSource4, GPIO_AF_4);
               
                        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4;
               
                        uIRQChannel = USART3_6_IRQn;
               
                        ptGpio  = GPIOB;
                        ptUsart = USART5;
                        break;
               
                case E_Uart6:
                        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,  ENABLE);
                        RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);

                        GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_5);
                        GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_5);
               
                        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;
               
                        uIRQChannel = USART3_6_IRQn;
               
                        ptGpio  = GPIOA;
                        ptUsart = USART6;
                        break;
//#endif
                default:
                        break;
        }
       
        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(ptGpio, &GPIO_InitStructure);

        USART_InitStructure.USART_BaudRate                          = uBaudRate;                              //波特率
        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(ptUsart, &USART_InitStructure);               
       
        NVIC_InitStruct.NVIC_IRQChannel                 = uIRQChannel;
        NVIC_InitStruct.NVIC_IRQChannelPriority = 0x01;
        NVIC_InitStruct.NVIC_IRQChannelCmd                 = ENABLE;
        NVIC_Init(&NVIC_InitStruct);
               
        USART_ITConfig(ptUsart, USART_IT_RXNE, ENABLE);
       
        USART_Cmd(ptUsart, ENABLE);
}


void uart_gpio(void)
{

     GPIO_InitTypeDef GPIO_InitStructure;
       
        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,  ENABLE);
        //RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE );
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_5;       
        GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IN;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
        GPIO_InitStructure.GPIO_OType =  GPIO_OType_PP;
        //GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;
        GPIO_Init(GPIOA, &GPIO_InitStructure);
}

void USART1_IRQHandler(void)  //接收中断  
{

        if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET){
       
               
                unsigned char ucData = USART_ReceiveData(USART1);
   
                usart_put_data_to_buf(g_ptUartBufInfos[0], ucData);
        }
}

void USART2_IRQHandler(void)
{
        if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET){
                unsigned char ucData = USART_ReceiveData(USART2);
                //printf("USART2 recv data: %c, %x\n", ucData, ucData);
                usart_put_data_to_buf(g_ptUartBufInfos[1], ucData);
        }
}

       
#ifdef STM32F030xC
void USART3_6_IRQHandler(void)
{
        unsigned char ucData;
       
        //uart_senddata("ok \n",4, E_Uart4);
        if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET){
                ucData = USART_ReceiveData(USART3);       
                //printf("USART3 recv data: %c, %x\n", ucData, ucData);
               
                usart_put_data_to_buf(g_ptUartBufInfos[2], ucData);
        }
       
        if(USART_GetITStatus(USART4, USART_IT_RXNE) != RESET){
                ucData = USART_ReceiveData(USART4);
       
                USART_SendData(USART4, ucData);
                //printf("USART4 recv data: %c, %x\n", ucData, ucData);
               
                usart_put_data_to_buf(g_ptUartBufInfos[3], ucData);
        }
       
        if(USART_GetITStatus(USART5, USART_IT_RXNE) != RESET){
                ucData = USART_ReceiveData(USART5);
               
                //printf("USART5 recv data: %c, %x\n", ucData, ucData);
               
                usart_put_data_to_buf(g_ptUartBufInfos[4], ucData);
        }
       
        if(USART_GetITStatus(USART6, USART_IT_RXNE) != RESET){
                ucData = USART_ReceiveData(USART6);
               
                //printf("USART6 recv data: %c, %x\n", ucData, ucData);
               
                usart_put_data_to_buf(g_ptUartBufInfos[5], ucData);
        }
}
#endif
回复

使用道具 举报

19

主题

95

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
329
金钱
329
注册时间
2018-8-2
在线时间
170 小时
发表于 2019-12-4 19:10:56 | 显示全部楼层
jack886 发表于 2019-3-7 23:47
我也是使用STM32F030CCT6怎么会没有中断呢?
你说的中断问题进不去是因为你需要编写中断函数,要不然堆 ...

你能发一下你的启动文件给我吗?我们启动文件不一样
回复

使用道具 举报

19

主题

95

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
329
金钱
329
注册时间
2018-8-2
在线时间
170 小时
发表于 2019-12-4 19:31:00 | 显示全部楼层
梦深处 发表于 2019-4-30 17:01
下面是我配置好的串口函数,测试了六个串口也都能进的去

* usart1: PA9, PA10

能发一下你的工程文件吗?我估计有点不一样
回复

使用道具 举报

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

本版积分规则



关闭

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

正点原子公众号

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

GMT+8, 2025-5-23 21:47

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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