#include // library with hardware specific parameters #include // low-level input/output library #include void set_timer(int t) { // write t directly to the device bypassing the processor's cache IOWR_32DIRECT(MKAVALONTIMER_0_BASE, 0, t); } int read_timer() { // read the timer directly from the device bypassing the processor's cache return IORD_32DIRECT(MKAVALONTIMER_0_BASE, 0); } void stop_timer() { // stop timer by writing 0 to word address 1 of the device (byte address 4) IOWR_32DIRECT(MKAVALONTIMER_0_BASE, 4, 0); } void start_timer() { // start timer by writing 1 to word address 1 of the device (byte address 4) IOWR_32DIRECT(MKAVALONTIMER_0_BASE, 4, 1); } int read_and_stop_timer() { return IORD_32DIRECT(MKAVALONTIMER_0_BASE, 4); } int main() { printf("Starting timer test\n"); fprintf(stderr,"Timer test\n(LCD output)"); stop_timer(); printf("timer = %d\n",read_timer()); printf("timer = %d\n",read_timer()); printf("start timer\n"); start_timer(); printf("timer = %d\n",read_timer()); printf("timer = %d\n",read_timer()); printf("read and stop = %d\n",read_and_stop_timer()); printf("timer = %d\n",read_timer()); return 0; }