32 lines
682 B
C
32 lines
682 B
C
#include "system.h"
|
|
#include "irq.h"
|
|
#include "timer.h"
|
|
#include "stdio.h"
|
|
|
|
|
|
#define TIMER_ALARM_ID TIMER_ALARM_0
|
|
#define TIMER_PERIOD_US (1000 * 1000)
|
|
|
|
void timer_alarm_0_isr(void)
|
|
{
|
|
timer_int_clear(TIMER_ALARM_ID);
|
|
timer_alarm_set(TIMER_ALARM_ID, timer_alarm_get(TIMER_ALARM_ID) + TIMER_PERIOD_US);
|
|
printf("time low count = %ld\r\n", timer_count_l_read_raw());
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
system_init();
|
|
timer_count_write(0);
|
|
timer_alarm_set(TIMER_ALARM_ID, TIMER_PERIOD_US);
|
|
timer_int_enable(TIMER_ALARM_ID);
|
|
irq_attach(TIMER_IRQ_0, timer_alarm_0_isr);
|
|
irq_enable(TIMER_IRQ_0);
|
|
|
|
while (1) {
|
|
|
|
}
|
|
|
|
return 0;
|
|
}
|