我的config.bib文件如下:
MEMORY
NK 80200000 01e00000 RAMIMAGE
RAM 82000000 01e00000 RAM
; FLASH 92000000 00100000 RESERVED
; Common RAM areas
AUD_DMA 80002000 00000800 RESERVED
SDIO_DMA 80010000 00010000 RESERVED
RES 80020000 00000800 RESERVED
ARGS 80020800 00000800 RESERVED
DBGSER_DMA 80022000 00002000 RESERVED
SER_DMA 80024000 00002000 RESERVED
IR_DMA 80026000 00002000 RESERVED
SLEEP 80028000 00002000 RESERVED
EDBG 80030000 00020000 RESERVED
DISPLAY 80080000 00180000 RESERVED
红色的是我自己添加的。我看到很多介绍文章中说的这个表最好是连续的,但是我找到了一个间隙,就加到了这里0x800(2K)的空间。不知可以吗?
AUD_DMA 段为什么从0x80002000开始而不是从0x80000000开始?
这里我还可以用的空间有多少?
然后我在intr.c文件中这样定义了两个变量
volatile int * m_Coder1 = (int *)0x80020000;
volatile int * m_Coder2 = (int *)0x80020004;
在OEMInterruptHandler()函数中。添加红色代码,并输出信息。可是为什么m_Coder1 ,m_Coder2变量内容乱变,没有规律。?不知道这样行吗?
if (irq == IRQ_EINT4_7 || irq == IRQ_EINT8_23) { // 4 or 5
// Find external interrupt number
mask = INREG32(&g_pPortRegs->EINTPEND);
mask &= ~INREG32(&g_pPortRegs->EINTMASK);
mask = (mask ^ (mask - 1)) >> 5;
irq2 = IRQ_EINT4;
while (mask != 0) {
mask >>= 1;
irq2++;
}
irq3 = INREG32(&g_pIntrRegs->EINTPEND);
if((irq3 & 0x00002000) == 0x00002000)// 13
{
*m_Coder1++;
RETAILMSG(1,(TEXT("m_Coder1 m_Coder1 = %d \r\n",*m_Coder1)));
}
RETAILMSG(1,(TEXT("m_Coder1 = %d \r\n",*m_Coder1)));
if((irq3 & 0x00000100) == 0x00000100 )// 8
{
*m_Coder2++;
RETAILMSG(1,(TEXT("m_Coder2 m_Coder2 = %d \r\n",*m_Coder2)));
}
RETAILMSG(1,(TEXT("m_Coder2 = %d \r\n",*m_Coder2)));
// Mask and clear interrupt
mask = 1 << (irq2 - IRQ_EINT4 + 4);
//
SETREG32(&g_pPortRegs->EINTMASK, mask);
OUTREG32(&g_pPortRegs->EINTPEND, mask);
// Clear primary interrupt
mask = 1 << irq;
OUTREG32(&g_pIntrRegs->SRCPND, mask);
OUTREG32(&g_pIntrRegs->INTPND, mask);
// From now we care about this irq
irq = irq2;
}