The following question is for Dragon board HSP 12 microcontroller by Freescale.
ID: 2080147 • Letter: T
Question
The following question is for Dragon board HSP 12 microcontroller by Freescale.
The following questions concern writing C code (a) Write some C code which will do the following: If bits 3, 2, 1 and 0 of PTH have the value 1001 (binary), write a 0xff to PORTB. Otherwise, write a 0 times 00 to FOR IB (Assume that all bits of PTII have been set up for input, and all bits of PORIB have been set up for output.) (b) Write some C code which sets bit* 1 and 3. and clear, bits 0 and 5 of the PTP. It should leave the other bits of PTP unchanged. (c) Write an IRQ interrupt service routine which increments POR IA every time the IRQ interrupt occurs.Explanation / Answer
a) if ((PTH & 0x0f) == 0x09) PORTB = 0xff;
else PORTB = 0x00;
b) PTP = PTP | 0x0A & 0x21;
c) interrupt void rti_isr(void)
{
PORTA = PORTA + 1; // Increment PORTA
CRGFLG = 0x80; // Clear RTI flag
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.