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
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.