请问一下,我在使用DM368的键盘扫描模块的时候,用查询方式工作正常,用中断模式的话中断来几次后就不来了,请问是什么原因?另外,我还发现DM368的中断标志寄存器不能清0(往对应中断位写1),读出来总是1,写1进去没效果,请问如何清除中断标志位?
VampireDaVinci:
1. 是不是得先把中断关了,清除标志位,再打开中断?
adam luofeng:
回复 VampireDaVinci:
关中断前和关中断后各全部清除了一次中断标志位,但绝大多数中断标志位还是1;
键盘扫描模块的中断可以来十次左右,然后再也不来了。
Tuff Li:
回复 adam luofeng:
Pls try below:
PERI_CLKCTL register: KeyScan clock source selection (KEYSCLKS) to 1(selects PLLC1AUXCLK clock Divider) with DIV3=749(i.e. 24MHZ/(DIV3+1) = 24MHZ/750 = 32KHz )
i.e. PERI_CLKCTL = 0x36ED04FC.
adam luofeng:
回复 VampireDaVinci:
INTC_FIQ0 = 0xFFFFFFFF;
INTC_FIQ1 = 0xFFFFFFFF;
INTC_IRQ0 = 0xFFFFFFFF;
INTC_IRQ1 = 0xFFFFFFFF;
// Disable all interrupts
INTC_EINT0 = 0x00000000;
INTC_EINT1 = 0x00000000;
// Interrupts disabled immediately. IRQ entry reflects all interrupts
INTC_INTCTL = 0x00000000;
// Set vector table base address
INTC_EABASE = ((unsigned int)(&irq_entry) & 0x1FFFFFF8);
// Clear all interrupt requests – write 1 to clear the interrupt
INTC_FIQ0 = 0xFFFFFFFF;
INTC_FIQ1 = 0xFFFFFFFF;
INTC_IRQ0 = 0xFFFFFFFF;
INTC_IRQ1 = 0xFFFFFFFF;
初始化代码运行到这时去读取中段标志寄存器,比如读INTC_IRQ0 ,其值为0xFFFFFFDF,绝大多数位还是为1,不知为什么不能清成零?
adam luofeng:
回复 Tuff Li:
我的按键扫描模块在查询方式下是可以正常工作的,如果PERI_CLKCTL 设置不正确,查询方式都会有问题。问题的关键是在中断方式下,按键扫描模块可以正常产生十次左右的中断,但之后,中断再也产生不了。关于这一块的系统级初始化代码如下:
if((PSC_KEYSCAN_MSTR & 0x3F) != 0x3)
{
while(PSC_PTSTAT & 0x1);
PSC_KEYSCAN_MCTL = ((PSC_KEYSCAN_MCTL & 0xFFFFFFE0) | 0x3);
PSC_PTCMD |= 1;
while(PSC_PTSTAT & 0x1);
}
PERI_CLKCTL_REG = ((PERI_CLKCTL_REG & 0xFC00FFFF) | (0x2ED<< 0x10)); PERI_CLKCTL_REG |= 0x10000000;
SYSCTL_PINMUX2 = ((SYSCTL_PINMUX2 & 0xFFFFFFC0) | 0x3F);
Feng Dong:
回复 adam luofeng:
There are some same issue is resolved by Tuff's suggestion. So Pls try.
adam luofeng:
回复 Feng Dong:
PERI_CLKCTL register: KeyScan clock source selection (KEYSCLKS) to 1(selects PLLC1AUXCLK clock Divider) with DIV3=749
PERI_CLKCTL_REG = ((PERI_CLKCTL_REG & 0xFC00FFFF) | (0x2ED<< 0x10)); PERI_CLKCTL_REG |= 0x10000000;
上面二者没什么区别吧?
我试了,都不行
Feng Dong:
回复 adam luofeng:
e2e.ti.com/…/63990.aspx
In this it seems you need set auto detect mode. Pls try
wang mingyin:
回复 Feng Dong:
请问你的irq_entry是什么?我中断程序不知道怎么写,能指点下吗,多谢