DT 8025 2016 Practical 3

From CERES
Revision as of 10:34, 19 August 2016 by Ceres (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Objectives

There are two objectives for this practical:

  • Get more insight into the working of the Raspberry Pi, particularly with respect to the interrupt controller and the timer.
  • Understand the issues involved in scheduling of real-time systems.


Instructions

In this pratical you will revise your program that displays the prime numbers and blinks the LED by using interrupt handlers

Part 1: Configure Interrupt Handling

Download the interrupt_2016.zip and get familiar with raspberry's interrupt controller and timer peripheral using the BCM2835 ARM peripherals datasheet

First, map the registers of the interrupt controller memory in file interrupts.h, i.e.,

typedef struct {
 /**
  * your mapping goes here
  **/
} interrupt_controller_t;

This will allows us to request timer interrupts as follows

Interrupt_Controller()->Enable_Basic_IRQs = RPI_BASIC_ARM_TIMER_IRQ;

Then, setup the ARM timer interval by specifying the countdown value within the Load register. This value is loaded into the Value register if the Load register has been written or the Value register has counted down to 0.

ArmTimer()->Load = /** your countdown value goes here**/

The Value register hold the current timer value and counts it down each timer clock until value 0 is reached. Then the value register is re-loaded from the timer Load register and the interrupt pending bit is set. Consider specifying the pre-scale bit when configure the ARM timer using the Control register.

RPI_GetArmTimer()->Control =
 /**
  * your configuration goes here
  */

Enable interrupt requests clearing the respective bit 7 of the current program status register. This operation is available through the given function call:

_enable_interrupts();

Part 2: Implement Interrupt Procedure

Your program should now periodically execute the following interrupt procedure for the specified time interval within the Load register.

void __attribute__((interrupt("IRQ"))) interrupt_vector(void)
{
  /**
   * your interrupt procedure goes here
   **/
} 

Modify this interrupt procedure to blink the LED while displaying the square roots on the monitor screen connected through the HDMI port.

Experiment with the timing interval and the pre-scale bit.