{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

P2-3 - file...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Spring 2007 Embedded Systems Programming Project 2-3 The value of time 1. Download and run the alarm.c routine. Observe the timing of the various outputs. Using supplied datasheets adjust the process to trigger an alarm every millisecond and still have the output continue at the same rate. 2. Create modules sys_clock.c and sys_clock.h to implement a globally available clock value of sys_clock. This value should be updated at least ten times per second and should be defined by a macro as follows in sys_clock.h. Make sure that your code can handle different values for TICKS_PER_SECOND #define TICKS_PER_SECOND 10 The only public function should be int sys_clock_init( void ) 3. Now modify the alive routine to utilize the alarm functionality to achieve much more control over the timing of on/off periods. Try to achieve ½ second ON and seconds OFF. Now modify your code to achieve 0.1 second ON and 4.9 seconds OFF. Following is a test routine (Your code MUST be callable by this routine with no changes).
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: /* file: p2-3.c */ #include <stdio.h> //#include "unistd.h" // no longer needed #include "dev/buttons.h" #include "dev/switches.h" #include "dev/redleds.h" #include "dev/greenleds.h" #include "alive.h" #include "sys_clock.h" int main ( void ) { int switches; printf( "\n\rStarting p2_3 (ESP N2 V2)\n\r" ); if ( sys_clock_init() != 0 ) { printf ( "No system clock available\n" ); return 4; } while (1) { switches = switches_get(); redleds_set ( switches ); alive(); // show that we are still alive //usleep(0); // no longer needed } return 0; } Spring 2007 Embedded Systems Programming Project 2-3 The value of time 4. Make sure that the alive routine will still work for various values of TICKS_PER_SECOND . So you will need to include sys_clock.h in alive.c so that it will stay at a constant ON/OFF period even when the clock period is changed. 5. Make sure that when the value of sys_clock overflows the routines using it do not stall or have other problems....
View Full Document

{[ snackBarMessage ]}