Switch debouncing

The switch on our board is pretty cheap and it de-bounces. For example, when I tried pushing the button with the tip of my nails then it showed jumps of two, but when I pressed it with the flesh of the tip of my finger then it showed jumps of 1. So, our button can show more than one jump when pressed in certain ways. If you are getting one or two extra jumps then don’t worry. If your count is off by hundreds or thousands, then there is a problem with your code.

Button presses

Give it some time between button presses. Say, half a second or a second.

Be aware of the space rules!

Make sure to follow the rules:
Labels should always be flush to the left.
Comments can be flush to the left or have spaces from the left
Every other statement should at least have a space or a tab from the left; this includes the lines that start with a dot, like .data, .text etc. as well as all the assembly statements.

Multi Sourced Interrupt

Since a port interrupt is multi-sourced, in general we need to check which pin is throwing the interrupt. However in our final, since we know that only S2 is throwing the interrupt,  we can assume that if we have entered the ISR it must be because push-button S2 was pressed. There is no need to check explicitly in the ISR which pin is causing the interrupt.

Typo in Prob. 6 (Final)

I skipped 4(SP) by mistake. It should be:

0(SP) ———————-
2(SP) ———————-
4(SP) ———————-
6(SP) ———————-
8(SP) ———————-

Port8 and CCS

In problems 3 and 4 you are not required to write any CCS code. However, if you do write some code to test out your answer, be aware that Port8 registers are defined in another header file. So, if if you want to write CCS code anyway, use port4 or lower, and then in  your exam use port8.

P1SEL Register Error

For some reason, if you put “bic.b #BIT2, &P1SEL” in your code then you will get an error at compile time. Apparently P1SEL is defined in a different header file.  Just avoid this line, P1SEL is set to zero by default anyway.

Problem 5 (Final)

The subroutine takes three inputs from the stack and places one output on the stack.