共2条
1/1 1 跳转至页
UART1 为什么UART1“代码”少时可以多时就有问题?
问
如下代码,请大家看看有什么不妥?调试时,加载所有程序(25K,ARM2132),
UART1执行一次后,就不再进入中断,真是郁闷
//TIME0中断设置
T0TC = 0;
T0PR = 0;
T0MCR = 0x03;
T0MR0 = Fpclk / 1;
T0TCR = 0x01;
VICIntSelect = 0x00;
VICVectCntl2 = 0x20 | 0x04; VICVectAddr2 = (uint32)IRQ_Timer0;
VICIntEnable = 1 << 0x04;
//UART0设置
U0LCR = 0x83;
Fdiv = (Fpclk / 16) / SIM100_BAUD;
U0DLM = Fdiv / 256;
U0DLL = Fdiv % 256;
U0LCR = 0x03;
U0FCR = 0x01;
U0IER = 0x01; VICVectCntl0 = 0x20 | 0x06;
VICVectAddr0 = (uint32)IRQ_UART0;
VICIntEnable = 1 << 0x06;
//uart1 中断设置
set.datab = 8;
set.stopb = 1;
set.parity = 0;
U1LCR = 0X83;
Fdiv = (Fpclk / 16) / GPS_BAUD;
U1DLM = Fdiv / 256;
U1DLL = Fdiv % 256;
U1LCR = 0x03;
U1FCR = 0x01; U1IER = 0x00; VICVectCntl1 = 0x20 | 0x07;
VICVectAddr1 = (uint32)IRQ_UART1;
VICIntEnable = 1 << 0x07;
IRQEnable(); 答 1: xx IRQEnable(); 放在U1LCR = 0X83;前试试。
//TIME0中断设置
//UART0设置
有没有使能IRQ中断?程序不全,别人不好理解,就更不好谈程序妥不妥了。
答 2: 换个方式试一下VICIntEnable = 1 << 0x04;
VICIntEnable = 1 << 0x06;
VICIntEnable = 1 << 0x07;
改为
VICIntEnable |= (1 << 0x04)|(1 << 0x06)|(1 << 0x07);
UART1执行一次后,就不再进入中断,真是郁闷
//TIME0中断设置
T0TC = 0;
T0PR = 0;
T0MCR = 0x03;
T0MR0 = Fpclk / 1;
T0TCR = 0x01;
VICIntSelect = 0x00;
VICVectCntl2 = 0x20 | 0x04; VICVectAddr2 = (uint32)IRQ_Timer0;
VICIntEnable = 1 << 0x04;
//UART0设置
U0LCR = 0x83;
Fdiv = (Fpclk / 16) / SIM100_BAUD;
U0DLM = Fdiv / 256;
U0DLL = Fdiv % 256;
U0LCR = 0x03;
U0FCR = 0x01;
U0IER = 0x01; VICVectCntl0 = 0x20 | 0x06;
VICVectAddr0 = (uint32)IRQ_UART0;
VICIntEnable = 1 << 0x06;
//uart1 中断设置
set.datab = 8;
set.stopb = 1;
set.parity = 0;
U1LCR = 0X83;
Fdiv = (Fpclk / 16) / GPS_BAUD;
U1DLM = Fdiv / 256;
U1DLL = Fdiv % 256;
U1LCR = 0x03;
U1FCR = 0x01; U1IER = 0x00; VICVectCntl1 = 0x20 | 0x07;
VICVectAddr1 = (uint32)IRQ_UART1;
VICIntEnable = 1 << 0x07;
IRQEnable(); 答 1: xx IRQEnable(); 放在U1LCR = 0X83;前试试。
//TIME0中断设置
//UART0设置
有没有使能IRQ中断?程序不全,别人不好理解,就更不好谈程序妥不妥了。
答 2: 换个方式试一下VICIntEnable = 1 << 0x04;
VICIntEnable = 1 << 0x06;
VICIntEnable = 1 << 0x07;
改为
VICIntEnable |= (1 << 0x04)|(1 << 0x06)|(1 << 0x07);
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【笔记】生成报错synthdesignERROR被打赏50分 | |
【STM32H7S78-DK评测】LTDC+DMA2D驱动RGBLCD屏幕被打赏50分 | |
【STM32H7S78-DK评测】Coremark基准测试被打赏50分 | |
【STM32H7S78-DK评测】浮点数计算性能测试被打赏50分 | |
【STM32H7S78-DK评测】Execute in place(XIP)模式学习笔记被打赏50分 | |
每周了解几个硬件知识+buckboost电路(五)被打赏10分 | |
【换取逻辑分析仪】RA8 PMU 模块功能寄存器功能说明被打赏20分 | |
野火启明6M5适配SPI被打赏20分 | |
NUCLEO-U083RC学习历程2-串口输出测试被打赏20分 | |
【笔记】STM32CUBEIDE的Noruletomaketarget编译问题被打赏50分 |