ENEL415 Post-Lab #5 Quiz B 1St December, 1998

ENEL415 Post-Lab #5 Quiz B 1St December, 1998

NAME ______ID # ______

ENEL415 Post-Lab #5 Quiz B 1st December, 1998

This is a closed book exam, except that students may make use of their OWN, CLEAN copies of the Motorola 68000 processor and SDS Quiz 1 reference cards and also the Motorola 68230 PI/T.

Answer in the space provided. Please ensure that you answer the question asked and not the question you think was asked. Provide appropriate documentation/explanation for your code and answers.

After completing each question, write in this table what you believe will be the mark you will receive for that question. This will allow me to keep track of student expectations

Question Number / Maximum Mark Available / Student Mark Estimate / Actual Mark
Awarded by T.A.
Q1 / 12 / / 12 / / 12
Q2 / 16 / / 16 / / 16
Q3 / 8 / / 8 / / 8
Q4 / 14 / / 14 / / 14

Total Marks

/ 50 / / 50 / / 50

Task 4 in Lab. 4 involved counting the number of clock ticks between heart beats. This task involved “polling” several signals. Task 4 would have been much easier if we had used an interrupt service routine (ISR). In this quiz, I’ll show you how to build on your knowledge from laboratory 5 to do Task 4 using a “C/C++” interrupt service routine.

NOTE: You can do the questions in this quiz in any order, but you will probably find it easier to start from Q1 and work through.

Useful background information to answer Q1

  • “C/C++” interrupt service routines must be turned into assembly code and therefore must follow EXACTLY the same conventions (coding practices) as assembly code ISR
  • THE ONLY DIFFERENCE between coding a “C/C++” interrupt service routine and a subroutine/function is that you must put the words #pragma interrupt in front of subroutine definition. All the things necessary to change a subroutine into an ISR are automatically handled by the compiler

Interrupt Service RoutineSubroutine/Function

#pragma interrupt

void SomeFunction(void) {void SomeFunction(void) {

Some Code Here  Same Code both times Some Code Here

}}

Q1) A) There are two changes to the subroutine/function assembler code that the compiler must make in order to turn it into an interrupt service routine. What are those changes? -- 4 marks

i)

ii)

B) There are certain basic rules that ISRs must follow. Why would it not be possible to change a subroutine with a prototype void SomeFunction(long int inpar)into an ISR? -- 1 mark

C) There is one change that the programmer must make to the “C/C++” function before it can be used as an ISR. That change is to ACKNOWLEDGE THE INTERRUPT during the ISR. What does ACKNOWLDEGE THE INTERRUPT mean and why do you need to do it? -- 2 marks

D) Write the “C/C++” interrupt service routinevoid IncrementCountISR(void)that will increment the external variable CLOCKCOUNT. You are provided with a function void AcknowledgeInterrupt(void) which you can call. – 4 marks

Q2) A) The next bit of the code is to build an assembly language routine that will set PORTA of PIT1

void ResetPIT(unsigned char *pt) routine to be able to read the Heart Pulse coming in on BIT 3. Complete the LINES below to correctly set the PIT for this operation. -- 3 marks

Assume that all the other operations on the other PI/T registers have been done for you.

.EXPORT _ResetPIT
_ResetPIT:

Code has already been placed here to Set Port General Control Register / Port A Control Register / Port B Control Register to 0 for you

Code has already been placed here to Set Port General Control Register / Port A Control Register / Port B Control Register so that we can have interrupts occurring on PORT A using pin H2 and NON-LATCHED INPUT on PORTA for you

RTS

B) Next we need to write a short C/C++ callable assembly language routine

voidSetUpandAllowInterrupts(void) which will set up the exception table to call the “C/C++” interrupt service routinevoid IncrementCountISR() when ever a Level 5 interrupt occurs, and then activate the processor to allow Level 5 interrupts to occur -- 6 marks

C)The following code has been written for a subroutine unsigned char ReadPIT(unsigned char *pt) that is designed to return a value from the PIT set up in the configuration given question 2A. The code is displayed using PROCOMM so there are no comments or labels.

For each line of the code state whether the line is correct, definitely wrong and going to cause a problem right now (ERROR), definitely wrong but probably not going to cause a problem right now (DEFECT). If it is going to cause a problem right now, correct that line. 7 marks

MOVE.L 8(SP), A5

MOVE.L 12(SP), D1

MOVE.B 0x90(A5), D0

AND.B #0x3, D0

RTS

Q3. We did not show how to set the bits of the PI/T registers in Q2to allow the correct form of modes, inputs and permit an H2 interrupt to occur when ever the H2 signal went from low to high causing an interrupt on an edge. This means that the interrupt will occur whenever the external clock signal (attached to H2) goes from low to high. Show how the bits in the PI/T registers must be set to allow the proper operation of the PI/T for this problem. Show Bits as 1 (set), 0 (clear) or X (don’t care).

No marks for worrying about Submode

This question is hard, and you will have to make some educated guesses about what is needed using the information available to you from the PI/T data sheet. I RECOMMEND that you tackle the easier problem set in Q4 before tackling this question) -- 8 marks

BIT 7 / BIT 6 / BIT 5 / BIT 4 / BIT 3 / BIT 2 / BIT 1 / BIT 0 / Register
PGCR
PADDR
PACR
PADR

Q4. We now have all the pieces of code needed to make Task 4 of Lab. 4 run under interrupt control

  • void IncrementCountISR(void)that will increment the external variable CLOCKCOUNT and acknowledge the interrupt
  • void ResetPIT(unsigned char *pt) that will set up the PI/T for you to allow interrupts on pin H2 and an input on Bit 3 of PIT1 PortA
  • void SetUpandAllowInterrupts(void) which will set up the exception table
  • unsigned char ReadPIT(unsigned char *pt)to read Bit 3 of PIT1 Port A

Design, Code and Document a C-LANGUAGE SUBROUTINE
long int CountHeartBeats(void) that will set up a PI/T to accept interrupts on PIN H2 on PIT1 (0x41A000) and read a heart signal (square wave ) attached to BIT 3 of PORT A of PIT1. The concept would be to wait until you see a heart signal and then start counting the interrupts that occur until you see the next heart signal. Then return the number of counts of the external clock between the Heart Beats.

There will be marks allocated for certain design components as well as the documented “C” code. This means that if you explain what needs to be done rather than how to do it, you will receive marks. Make sure you use the 4 “C” subroutines you have already developed and DON’T RECODE THOSE PORTIONS OF THE PROBLEM -- 14 marks