Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Rewrite HW 1 program. Incorporate the IRQ interrupt to reset the clock #include

ID: 3561922 • Letter: R

Question

Rewrite HW 1 program. Incorporate the IRQ interrupt to reset the clock

#include /* common defines and macros */

#include /* derivative information */

#pragma LINK_INFO DERIVATIVE "mc9s12dg256b"

#include "main_asm.h" /* interface to the assembly module */

int i,j,k,l;

void main()

{

DDRB=0b11111111; // sets PORT B as an output

DDRJ=0b11111111; // sets PORT J as an output

DDRP=0b11111111; // sets PORT P as an output

PTJ=0b00000000; // disables LEDs

while(1){

  

for(i=0;i<10;i++)

for(j=0;j<10;j++)

for(k=0;k<10;k++)

for(l=0;l<6;l++){

  

seg7dec(l,3);

ms_delay(10);

seg7dec(k,2);

ms_delay(10);

seg7dec(j,1);

ms_delay(10);

seg7dec(i,0);

ms_delay(10);

}

}

}

Explanation / Answer

#include /* common defines and macros */

#include /* derivative information */

#pragma LINK_INFO DERIVATIVE "mc9s12dg256b"

#include "main_asm.h" /* interface to the assembly module */

int i,j,k,l;

void main()

{

DDRB=0b11111111; // sets PORT B as an output

DDRJ=0b11111111; // sets PORT J as an output

DDRP=0b11111111; // sets PORT P as an output

PTJ=0b00000000; // disables LEDs

INTCR=0x40;// enable IRQ

while(1){

  

for(i=0;i<10;i++)

for(j=0;j<10;j++)

for(k=0;k<10;k++)

for(l=0;l<6;l++){

  

seg7dec(l,3);

ms_delay(10);

seg7dec(k,2);

ms_delay(10);

seg7dec(j,1);

ms_delay(10);

seg7dec(i,0);

ms_delay(10);

}

}

}

@interrupt void irq_isr(void)

{

Do what needs to be done on interrupt

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote