Lab 8
Lab 8
Lab 8
2014400138
LAB #008
“Multiple Interrupts”
“Power Saving”
Motivation
In this experiment, we will study multiple interrupts where one interrupt will invoke
another interrupt. Besides, we will use special instructions to observe their effects in power
saving when they are used with interrupts. So in this experiment you will learn
● programming output compare timer function to generate an interrupt.
● programming an interrupt handler to generate another interrupt.
● using an interrupt handler to handle multiple interrupt requests.
● observing power saving when special instructions are used.
When you pressed the push button on the LPC4088 which is shown in the figure, you can
give External Interrupt to board.
In External.h file:
- What is the pin name of the pin which is connected to Push Button? (PX_Y) __
P2_10 0.5 pts
- Write the IOCON address of the push button to
IOCON_PUSH_BUTTON_ADDRESS. 0x4002 C128 0.5 pts
- Write the address of the External Interrupt Flag register to EXT_ADDRESS
0x400F C140 0.5 pts
In External.c file:
Student Names:Zeki TEL 2013400015 İhsan Berkan BALABAN
2014400138
In order to change the power mode of the board. You will use SCR (System Control
Register) and PCON register.
In PowerConsumptionTest method:
a) Sleep Mode
In this part, you should change the LAB_8 code for entering the sleep mode. Your code
should go to Sleep Mode after you pressed Joystick Left Button and turn on all the 4 LEDs.
(When you pressed the push button on the LPC4088 which is shown in the figure, the
EINT0_IRQHandler will be called and board will wake up)
- What should be the value of SCR register value for Sleep Mode?
SCR &=~(4); 0.5 pts
- What should be the value of PCON register value for Sleep Mode?
PCON&=~(3);0.5 pts
Write the necessary code in SleepMode method and call it when Joystick Left Button is
pressed.
- Find Current while LED on in the Sleep Mode. 10.0 0.5 pts
Student Names:Zeki TEL 2013400015 İhsan Berkan BALABAN
2014400138
(Hint: You can check it is in sleep mode or not by pressing joystick center button. If no led
is turned off, it means it is in sleep mode)
(Hint: Do not forget __WFI();)
Your code should go to Deep Sleep Mode after you pressed Joystick Right Button and turn on
all the 4 LEDs.
- What should be the value of SCR register value for Deep Sleep Mode?
SCR|=1<<2; 0.5 pts
- What should be the value of PCON register value for Deep Sleep Mode?
PCON&=~(3);0.5 pts
Write the necessary code in DeepSleepMode method and call it when Joystick Right Button
is pressed.
- Find Current while LED on in the Deep Sleep Mode. 9.4 0.5 pts
Your code should go to Power Down Mode after you pressed Joystick Up Button and turn on
all the 4 LEDs.
- What should be the value of SCR register value for Power Down Mode?
SCR|=1<<2; 0.5 pts
- What should be the value of PCON register value for Power Down Mode?
PCON&=~(2);0.5 pts
Write the necessary code in PowerDownMode method and call it when Joystick Up Button is
pressed.
- Find Current while LED on in the Power Down Mode. 9.4 0.5 pts
Your code should go to Deep Power Down Mode after you pressed Joystick Up Button and
turn on all the 4 LEDs.
- What should be the value of SCR register value for Deep Power Down Mode?
SCR|=1<<2; 0.5 pts
- What should be the value of PCON register value for Deep Power Down Mode?
PCON&=~(3);0.5 pts
Write the necessary code in DeepPowerDownMode method and call it when Joystick Down
Button is pressed.
- Find Current in the Deep Power Down Mode. 7,4 0.5 pts
In previous lab, you used polling method for sending trigger signal to Ultrasonic sensor.
However in this lab you will use Timer2 and Timer3 interrupts and also you will send trigger
signal via Timer2 interrupt.
Vcc VU
GND GND
Write the Correct Configuration for EMR (Toggle Output Value and Initial value is HIGH)
uint32_t temp=TIMER2->EMR;
- temp|=1<<5;
- temp|=1<<6;
- TIMER2->EMR=temp; 0.5 pts
Student Names:Zeki TEL 2013400015 İhsan Berkan BALABAN
2014400138
In this part, you will write codes into update method for:
Student Names:Zeki TEL 2013400015 İhsan Berkan BALABAN
2014400138
- When Ultrasonic Sensor detects obstacles which are closer than 7cm, turn on all the
LEDs. ___________ 0.5 pts
- When Ultrasonic Sensor detects obstacles which are in the range of 7cm and 12cm , turn
on LED1, LED2 and LED3. ___________ 0.5 pts
- When Ultrasonic Sensor detects obstacles which are in the range of 12cm and 20cm , turn
on LED1 and LED2.
- When Ultrasonic Sensor detects obstacles which are in the range of 20cm and 30cm , turn
on LED1. ___________ 0.5 pts
- When Ultrasonic Sensor detects obstacles which are far from 30 cm, turn off all the
LEDs. ___________ 0.5 pts
In part 2, you have used four power saving modes. Can you use all of them in the update
method of Part 4? If you think that a method can be used in part 4, then use it and write your
observations. If not, then write the reason.