完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
控制台串口改成了USART3,初始化USART1之后,进USART1接收中断,就会跳到HardFault_Handler中断里面出不来了,是什么问题。工程是用MounRiver Studio创建的RT-Thread工程
void USART1_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); //UART1中断函数 void USART1_IRQHandler(void) { GET_INT_SP(); rt_interrupt_enter(); if(USART_GetiTStatus(USART1, USART_IT_RXNE) != RESET) { USART_ClearITPendingBit(USART1,USART_IT_RXNE); uart0_rev->rev_buf[uart0_rev->rev_len] = USART_ReceiveData(USART1); //接收数据字节 if(++uart0_rev->rev_len>=UART0_MAX_LEN) { uart0_rev->rev_len = 0; } } rt_interrupt_leave(); FREE_INT_SP(); } static int App_Uart0_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); //USART1外设时钟 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA , ENABLE); //GPIOA外设时钟 /* USART1 TX-->A.9 RX-->A.10 */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 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_Tx | USART_Mode_Rx; USART_Init(USART1, &USART_InitStructure); USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); USART_Cmd(USART1, ENABLE); rt_memset(uart0_rev,0,sizeof(struct Uart0_Rev)); return 0; } void aliiot_send(u8 *buf, int len ) { rt_enter_critical(); while (len--) { USART_SendData(USART1, *buf); while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET) /* waiting for sending finish */ { } buf++; } rt_exit_critical(); } INIT_DEVICE_EXPORT(App_Uart0_Init); |
|
相关推荐
1个回答
|
|
你好,看帖出来的代码没有发现什么问题
|
|
|
|
只有小组成员才能发言,加入小组>>
505 浏览 1 评论
CH579M+RT-Thread,RTC从Sleep模式唤醒失败是什么原因?
2899 浏览 2 评论
2387 浏览 1 评论
848浏览 2评论
CH32F103C8T6使用当前官网上的CDC例程会出现设备描述符请求失败
392浏览 1评论
670浏览 1评论
riscv-none-embed-objcopy: \'PWM_Output.elf\': No such file这个咋解决,
406浏览 1评论
501浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-12 23:42 , Processed in 1.084942 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号