Attached video demonstrates that the LEDs on McLab2 are sequentially turned on every X milliseconds. The value of X is determined according to the last digit of
your student number as shown below.
X = 89.6 milliseconds if last digit of student number is 0. (You can use!!!!!)
The oscillation frequency of the crystal used in the system is 1 MHz and the code below
implements this functionality. What is the value of TMR0 in the code?
#include
void slide_led(void);
void interrupt isr_vector (void)
{
INTCONbits.GIE = 0;
if (INTCONbits.T0IF)
{
INTCONbits.T0IF = 0;
TMR0 = __;
slide_led();
}
INTCONbits.GIE = 1;
}
void main(void)
{
TRISB = 0;
OPTION_REGbits.T0CS = 0;
OPTION_REGbits.T0SE = 0;
OPTION_REGbits.PSA = 0;
OPTION_REG |= 0b00000110; // prescaler is configured here.
OPTION_REG &= 0b11111110; // prescaler is configured here.
PORTBbits.RB0 = 1;
INTCONbits.T0IE = 1;
INTCONbits.GIE = 1;
while (1)
{
}
return;
}
void slide_led(void)
{
PORTB = PORTB*2;
if (PORTB == 16)
PORTB = 1;
}
Please only write the value of TMR0 onto your solution. No need to write whole code.
TMR0 = ____
Also please explain your solution in one sentence.