140 likes | 279 Views
LAB04-Core Peripherals -Experiment-. Speaker: Chuang Chi Chiou Advisor: Prof. Chun-Yao Wang Oct 27, 2003. Department of Computer Science National Tsing Hua University. Goal of This Lab. Understand the main mechanism of Timer/Interrupt operations. How to Perform Timer/Interrupt.
E N D
LAB04-Core Peripherals-Experiment- Speaker: Chuang Chi Chiou Advisor: Prof. Chun-Yao Wang Oct 27, 2003 Department ofComputer Science National Tsing Hua University
Goal of This Lab • Understand the main mechanism of Timer/Interrupt operations SoC Design Laboratory
How to Perform Timer/Interrupt • With two methods: -Pure software : Armulator -Hardware :Multi-ICE • In this lab,we choose hardware method SoC Design Laboratory
Interrupt Processing Flow 1 Memory AP IRQ Counter Timers Interrupt Controller Vector Branch Table IRQ(0x18) Interrupt_Handler User Code User Code Interrupt_Service_Routine: -ISR tasks -Clear IRQ Interrupt_Handler : -Check IRQ source -Branch to corresponding Interrupt Service Routine Interrupt_Service_Routine SoC Design Laboratory
The Important functions of Source code • LoadTimer, WriteTimerCtrl, ReadTimer, ClearTimer: Timer related functions • enableIRQ: The IRQ enable bit in the CPSR is set to enable IRQ SoC Design Laboratory
Interrupt Processing Flow Memory AP IRQ Counter Timers Interrupt Controller Vector Branch Table IRQ(0x18) 2 Interrupt_Handler User Code User Code Interrupt_Service_Routine: -ISR tasks -Clear IRQ Interrupt_Handler : -Check IRQ source -Branch to corresponding Interrupt Service Routine Interrupt_Service_Routine SoC Design Laboratory
The Important Functions of Source code • Install_Handler: This function installs the IRQ handler at the branch vector table at 0x18 SoC Design Laboratory
Interrupt Processing Flow Memory AP IRQ Counter Timers Interrupt Controller Vector Branch Table IRQ(0x18) 3 Interrupt_Handler User Code 3 User Code Interrupt_Service_Routine: -ISR tasks -Clear IRQ Interrupt_Handler : -Check IRQ source -Branch to corresponding Interrupt Service Routine Interrupt_Service_Routine SoC Design Laboratory
The Important Functions of Source code • myIRQHandler: This is the user’s IRQ handler. It performs the timer ISR in this example SoC Design Laboratory
The mechanism of Timer/Interrupt operations int main(void) { int IRQ0_STATUS_ADDR = 0x14000000; int IRQ0_RAWSTAT_ADDR = 0x14000004; int IRQ0_ENABLESET_ADDR = 0x14000008; int IRQ0_ENABLECLR_ADDR = 0x1400000C; int *IRQ0_STATUS, *IRQ0_RAWSTAT, *IRQ0_ENABLESET, *IRQ0_ENABLECLR; unsigned *irqvec = (unsigned *)0x18; Install_Handler( (unsigned)myIRQHandler, irqvec ); /* Install user’s IRQ Handler */ enable_IRQ(); IRQ0_STATUS = (int *) IRQ0_STATUS_ADDR; IRQ0_RAWSTAT = (int *) IRQ0_RAWSTAT_ADDR; IRQ0_ENABLESET = (int *) IRQ0_ENABLESET_ADDR; IRQ0_ENABLECLR = (int *) IRQ0_ENABLECLR_ADDR; IRQ0_ENABLESET = 0x0021; installs the memory addresses of IRQ Enables the IRQs of Timer0 and SWI SoC Design Laboratory
The mechanism of Timer/Interrupt operations LoadTimer(64); // load timer value WriteTimerCtrl(0xC8); // enable the timer ……………………….. ……………………….. ……………………….. ……………………….. } Sets the timer down-counting from 64 and triggers the timer to start downcounting. decide the operation mode and choose the divisor value SoC Design Laboratory
Steps of This Lab 1.Assemble AP,CM and LM carefully 2.Safely assemble Multi-ICE on CM 3.Turn on the power 4.Execute Multi-ICE server and click the Auto-Configuration icon 5.Execute CodeWarrior and create a new ARM Executable Image project ,add irq.c to the project ,make the project 6.Open AXD 7.Select Option->Configure Target and select Multi-ICE 8.Run the project finally SoC Design Laboratory
Exercise • Use the Timer/Interrupt to evaluate the performance of other applications • Spec: Use Timer/Interrupt to calculate the time of ssram.c when executing. • Hint: You can start Timer/Interrupt when ssram.c begin to execute, and you can count how many times the interrupt occurred. • Note: The period of Timer clock is 0.5 s. SoC Design Laboratory
Discussion • How to use multi-Timer/Interrupt • Give some suggestions for this lab SoC Design Laboratory