diff --git a/examples/systick_irq/systick.h b/examples/systick_irq/systick.h index e681d818f41432573f6f09283b05fcfb939ac016..8aaa3ef5e3e9a93390c38233d28d4f8e6ff1b792 100644 --- a/examples/systick_irq/systick.h +++ b/examples/systick_irq/systick.h @@ -29,11 +29,11 @@ void systick_init(void) /* Clear any existing IRQ */ SysTick->SR &= ~SYSTICK_SR_CNTIF; -#if 0 +#if 1 /* Set the tick interval to 1ms for normal op */ SysTick->CMP = (SYSTEM_CORE_CLOCK/1000)-1; #else - /* Set the tick interval to 100ms for debug */ + /* Set the tick interval to 1s for debug */ SysTick->CMP = (SYSTEM_CORE_CLOCK)-1; #endif @@ -49,19 +49,16 @@ void systick_init(void) #if 1 /* * SysTick ISR just counts ticks + * note - the __attribute__((interrupt)) syntax is crucial! */ -void SysTick_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); -//void SysTick_Handler(void) __attribute__((interrupt("interrupt"))); +void SysTick_Handler(void) __attribute__((interrupt)); void SysTick_Handler(void) { /* clear IRQ */ - SysTick->SR &= ~SYSTICK_SR_CNTIF; + SysTick->SR &= 0; /* update counter */ systick_cnt++; - - printf("systick_cnt = 0x%08X\n\r", systick_cnt); - } #endif diff --git a/examples/systick_irq/systick_irq.c b/examples/systick_irq/systick_irq.c index db9f4c4f7c3f3c490888468ab699b10d08261040..589ed89287002e0b2a482501ff66e0195b119aa1 100644 --- a/examples/systick_irq/systick_irq.c +++ b/examples/systick_irq/systick_irq.c @@ -28,27 +28,21 @@ int main() systick_init(); printf("done.\n\r"); -#if 1 +#if 0 // Debugging - does ISR run & inc counter? // this section shows that IRQs during print will reset system, but during // inf while() do not. - //while(1) - //for(int i=0;i<20;i++) - //{ - //printf("i = %d ", i); - printf("CNT = 0x%08X ", SysTick->CNT); - printf("systick_cnt = 0x%08X\n\r", systick_cnt); - //} // does cnt inc? - //uint32_t pcnt = systick_cnt; + uint32_t pcnt = systick_cnt; while(1) { - //if(pcnt != systick_cnt) - //{ - // printf("systick_cnt = %d\n\r", systick_cnt); - // pcnt = systick_cnt; - //} + if(pcnt != systick_cnt) + { + printf("CNT = 0x%08X ", SysTick->CNT); + printf("systick_cnt = %d\n\r", systick_cnt); + pcnt = systick_cnt; + } } #else // Testing 1ms Systick