static void test_operation(void) { if (opcode == 0) { dump_timer_regs(); } else if (opcode == 1) { write_cntp_tval(op1); write_cntp_ctl(op2); } }
void user_init(void) { sdk_uart_div_modify(0, UART_CLK_FREQ / 115200); xTaskCreate(timerRegTask, (signed char *)"timerRegTask", 1024, NULL, 2, NULL); TIMER(0).CTRL = VAL2FIELD(TIMER_CTRL_CLKDIV, TIMER_CLKDIV_256) | TIMER_CTRL_RELOAD; TIMER(0).LOAD = 0x200000; TIMER(1).LOAD = VAL2FIELD(TIMER_CTRL_CLKDIV, TIMER_CLKDIV_256); DPORT.INT_ENABLE |= DPORT_INT_ENABLE_TIMER0 | DPORT_INT_ENABLE_TIMER1; _xt_isr_attach(INUM_TIMER_FRC1, frc1_handler); _xt_isr_unmask(1<<INUM_TIMER_FRC1); _xt_isr_attach(INUM_TIMER_FRC2, frc2_handler); _xt_isr_unmask(1<<INUM_TIMER_FRC2); TIMER(0).CTRL |= TIMER_CTRL_RUN; TIMER(1).CTRL |= TIMER_CTRL_RUN; dump_timer_regs("timer regs during user_init"); dump_timer_regs("#2 timer regs during user_init"); dump_timer_regs("#3 timer regs during user_init"); }
void user_init(void) { sdk_uart_div_modify(0, UART_CLK_FREQ / 115200); xTaskCreate(timerRegTask, (signed char *)"timerRegTask", 1024, NULL, 2, NULL); TIMER_FRC1_CTRL_REG = TIMER_CTRL_DIV_256|TIMER_CTRL_INT_EDGE|TIMER_CTRL_RELOAD; TIMER_FRC1_LOAD_REG = 0x200000; TIMER_FRC2_CTRL_REG = TIMER_CTRL_DIV_256|TIMER_CTRL_INT_EDGE; DP_INT_ENABLE_REG |= INT_ENABLE_FRC1|INT_ENABLE_FRC2; _xt_isr_attach(INUM_TIMER_FRC1, frc1_handler); _xt_isr_unmask(1<<INUM_TIMER_FRC1); _xt_isr_attach(INUM_TIMER_FRC2, frc2_handler); _xt_isr_unmask(1<<INUM_TIMER_FRC2); TIMER_FRC1_CTRL_REG |= TIMER_CTRL_RUN; TIMER_FRC2_CTRL_REG |= TIMER_CTRL_RUN; dump_timer_regs("timer regs during user_init"); dump_timer_regs("#2 timer regs during user_init"); dump_timer_regs("#3 timer regs during user_init"); }
void timerRegTask(void *pvParameters) { while(1) { printf("state at task tick count %ld:\r\n", xTaskGetTickCount()); dump_timer_regs(""); /* for(int i = 0; i < 16; i++) { printf("int 0x%02x: 0x%08x (%d)\r\n", i, isr[i], seen_isr[i]); } printf("INUM_MAX count %d\r\n", max_count); */ printf("frc1 handler called %ld times, last value 0x%08lx\r\n", frc1_handler_call_count, frc1_last_count_val); printf("frc2 handler called %ld times, last value 0x%08lx\r\n", frc2_handler_call_count, frc2_last_count_val); vTaskDelay(500 / portTICK_RATE_MS); } }