diff --git a/main.c b/main.c index a59aac4..9ca5e20 100644 --- a/main.c +++ b/main.c @@ -102,22 +102,22 @@ void start_signal() { PWMGenEnable(PWM0_BASE, PWM_GEN_1); } +uint8_t cpu_load_active = 0; // Clock_isActive does not change uint32_t cpu_load_count(void) { uint32_t i = 0; - TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT); - TimerEnable(TIMER1_BASE, TIMER_A); // start one-shot timer - while (!(TimerIntStatus(TIMER1_BASE, false) & TIMER_TIMA_TIMEOUT)) + cpu_load_active = 1; + Clock_start(cpu_clock); + while (cpu_load_active) i++; return i; } +void cpu_timer_end(void) { + cpu_load_active = 0; +}; + void start_cputimer() { - // initialize timer 1 in one-shot mode for polled timing - SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); - TimerDisable(TIMER1_BASE, TIMER_BOTH); - TimerConfigure(TIMER1_BASE, TIMER_CFG_ONE_SHOT); - TimerLoadSet(TIMER1_BASE, TIMER_A, gSystemClock/100); // 10ms interval // baseline load cputime_unloaded = cpu_load_count(); } @@ -133,7 +133,6 @@ int main(void) start_signal(); start_sampler(); ButtonInit(); - start_cputimer(); Crystalfontz128x128_Init(); // Initialize the LCD display driver Crystalfontz128x128_SetOrientation(LCD_ORIENTATION_UP); // set screen orientation @@ -159,6 +158,8 @@ void task0_func(UArg arg1, UArg arg2) void capture_waveform(UArg arg1, UArg arg2) { IntMasterEnable(); + start_cputimer(); + while(true) { Semaphore_pend(capture_sem, BIOS_WAIT_FOREVER); diff --git a/rtos.cfg b/rtos.cfg index 6f06a7a..821338e 100644 --- a/rtos.cfg +++ b/rtos.cfg @@ -593,3 +593,6 @@ var task5Params = new Task.Params(); task5Params.instance.name = "user_input"; task5Params.priority = 6; Program.global.user_input = Task.create("&handle_user_input", task5Params); +var clock1Params = new Clock.Params(); +clock1Params.instance.name = "cpu_clock"; +Program.global.cpu_clock = Clock.create("&cpu_timer_end", 10, clock1Params);