WebCT Quiz 2 - 1. Complete the following code segment as...

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

View Full Document Right Arrow Icon
Complete the following code segment as per the comments/pseudocode provided. /* The code will count the number of Timer 0 overflows that occur and will keep track of time in seconds. The system clock is at 22.1184 MHz*/ #include <c8051.h> int Counts = 0, Seconds = 0; void main(void) { Sys_Init(); /* System Initialization*/ /* Initialize Timer 0 */ CKCON |=(NUMBER 1); /* Timer0 uses SYSCLK as source */ TMOD &= (NUMBER 2); /* clear the 4 least significant mode register bits, Timer 0 in mode 0 */ TR0 = (NUMBER 3); /* Stop Timer0 */ TL0 = 0; /* Clear low byte of Timer0*/ TH0 = (NUMBER 4); /* Clear high byte of Timer0 */ ET0 = (NUMBER 5); /* enable Timer0 Interrupt request */ EA = (NUMBER 6); /* enable global interrupts */ while (1) { TR0 = (NUMBER 7); /* Start Timer0 */ printf("\r Number of Overflows = %d, Seconds = %d", Counts, Seconds); } } void T0_ISR ( void ) interrupt 1 /*Interrupt service routine*/ { Counts++; /* increment overflow counter*/ if ( Counts == (NUMBERS 8) ) /* Update seconds */
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/07/2008 for the course ENGR 2350 taught by Professor Fukanari during the Spring '08 term at Rensselaer Polytechnic Institute.

Page1 / 4

WebCT Quiz 2 - 1. Complete the following code segment as...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online