42 lines
803 B
C
42 lines
803 B
C
#include "libsys.h"
|
|
|
|
|
|
void handler(void)
|
|
{
|
|
volatile UINT32 *pGPIO0 = (UINT32*)SYS_GPIO_0_BASE;
|
|
volatile UINT32 *pTim_stat = (UINT32*)SYS_ITIM_STAT;
|
|
volatile UINT32 *pTim_cmp = (UINT32*)SYS_ITIM0_CMP;
|
|
if (*pTim_stat & 1)
|
|
{
|
|
(*pTim_cmp)++;
|
|
(*pGPIO0)++;
|
|
|
|
*pTim_stat = 1;
|
|
}
|
|
|
|
}
|
|
|
|
int main (void)
|
|
{
|
|
volatile UINT32 *pTim_ctrl = (UINT32*)SYS_ITIM_CTRL;
|
|
volatile UINT32 *pTim_stat = (UINT32*)SYS_ITIM_STAT;
|
|
volatile UINT32 *pTim_cnt = (UINT32*)SYS_ITIM0_CNT;
|
|
volatile UINT32 *pTim_cmp = (UINT32*)SYS_ITIM0_CMP;
|
|
volatile UINT32 *pGPIO0 = (UINT32*)SYS_GPIO_0_BASE;
|
|
|
|
*pGPIO0 = 1;
|
|
|
|
interrupt_register(SYS_INT_TIMER, handler);
|
|
interrupt_enable(SYS_INT_TIMER);
|
|
|
|
*pTim_cnt = 0;
|
|
*pTim_cmp = 1999;
|
|
*pTim_stat = 1;
|
|
*pTim_ctrl = 3;
|
|
|
|
while(1);
|
|
|
|
return 0;
|
|
}
|
|
|