完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
tify;text-indent: 40px;">大家好
一直在玩那个mcu但是我不能将UART IRQ DR(数据寄存器)设置为空 IO引脚中断按预期工作但在CR2函数中设置TIEN后,enableInterrupts()会冻结整个芯片并且ISR永远不会被触发它只是挂在该函数上 我的代码: ISR(UART1_T_TXE_vector) { PD_ODR ^ = 1 以下为原文 hello everyone been playing with that mcu for a while but I cant set up UART IRQ DR(data register) empty IO pins interrupts work as expected but after setting TIEN in CR2 function enableInterrupts() freezes whole chip and ISR is never hit it just hangs on that function my code: ISR(UART1_T_TXE_vector) { PD_ODR ^= 1<<3; } int main( void ) { UART1_CR1_.M = 1;//9 bit data inc parity bit UART1_CR3 |= 0x20;//2 stop bits UART1_BRR2 = (u8)0x02;//baud setting 9600 at 16MHz UART1_BRR1 = (u8)0x68; UART1_CR1_.PCEN = 1;//parity check enable UART1_CR1_.PS = 0;//even parity UART1_CR2_.TEN = 1;//TX enable //UART1_CR2_.TIEN = 1;//DR empty IRQ enable UART1_CR2_.REN = 1;//RX enable enableInterrupts(); u8 x = 0; u8 buf[10] = { 65,66,67,68,69,70,71,72,73,74 }; while (x<10) { UART1_DR = buf[x]; while (UART1_SR_.TXE == 0); x++; } anyone have an idea whats wrong? does it require some additional settings? |
|
相关推荐
1个回答
|
|
你好。你现在可能已经解决了你的问题,但对于其他任何人来说:
您需要添加到中断处理程序例程。您需要复位发出中断信号的位。请参阅参考手册。在UART状态寄存器中,有些位在特定中断时变为高电平。弄清楚哪一位变高了。处理那种情况。然后重置该位。 例如,如果由于可以读取数据而发生中断,则读取数据然后重置RXNE位。全部在中断处理程序内。 以上来自于谷歌翻译 以下为原文 Hello. You probably solved your issue by now, but for anyone else who comes along: You need to add to interrupt handler routine. You need to reset the bit that signals an interrupt has occurred. Refer to the reference manual. In the UART Status register there are bits which go high for particular interrupts. Figure out which bit went high. Handle that situation. Then reset that bit. For example, if the interrupt occurred because data is available to be read then you read the data and then reset the RXNE bit. All inside the interrupt handler. |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2738 浏览 1 评论
3241 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1810 浏览 1 评论
3650 浏览 6 评论
6039 浏览 21 评论
1339浏览 4评论
201浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
353浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
444浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
275浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 10:03 , Processed in 2.370685 second(s), Total 76, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号