Download presentation
Presentation is loading. Please wait.
1
Programmable Interrupt Timer Modules PIT0, PIT1, PIT2, PIT3
2
Memory Map
3
Status Register
4
Status Register Prescaler Field
5
Status Register Control / Status Fields
6
Modulus Register
7
Count Register
8
Functional Operation
9
Example Program /* ----------------------------------------------------------------------------- This example program exercises the Programmable Interval Timer in the 5282 CPU ----------------------------------------------------------------------------- */ #include "predef.h" #include /* ----- function prototypes ----- */ extern "C" { void UserMain(void * pd); /* This function sets up the 5282 interrupt controller */ void SetIntc(int intc, /* Interrupt Controller Number */ long func, /* Address of Interrupt Service Routine */ int vector, /* Vector Table Number */ int level, /* Interupt Priority Level */ int prio /* Interrupt Priority Sub Level */ ); } /* ----- global variables ----- */ volatile DWORD pit_count = 0;
10
Example Program (cont) /* ------------------------------------------------------------------------------ PIT Interrupt Service Routine ------------------------------------------------------------------------------- */ INTERRUPT(my_pit_func, /* Name of Interrupt Service Routine */ 0x2600 /* Mask - Enter Supervisor Mode, Set Interrupt Mask */ ) { static WORD led_count; WORD tmp = sim.pit[1].pcsr; /* use PIT 1 */ /* Initialize PIT 1 (0 --> 7-4, 1 --> 3-0 ) */ tmp &= 0xFF0F; tmp |= 0x0F; sim.pit[1].pcsr = tmp; /* You can add your ISR code here. - Do not call any RTOS function with pend or init in the function name - Do not call any functions that perform a system I/O read, write, printf, iprint etc. */ putleds(led_count++); pit_count++; }
11
Example Program (cont) /* ------------------------------------------------------------------------------------- PIT Setup function. See chapter 19 of the 5282 users manual for details ------------------------------------------------------------------------------------- */ void SetUpPITR(int pit_ch, /* Pit Channel Number */ WORD clock_interval, /* Timer Modulus Number */ BYTE pcsr_pre /* Timer Prescaler - See Users Manual table 19-3 */ ) { WORD tmp; if ((pit_ch 3)) return; /* Check for valid PIT */ /* populate the interrupt vector in the interrupt controller */ SetIntc(0, /* Interrupt Controller Number */ (long)&my_pit_func, /* Address of Interrupt Service Routine */ 55 + pit_ch, /* Vector Table Number */ 2, /* Interupt Priority Level */ 3 /* Interrupt Priority Sub Level */ ); /* set up PIT Control & Status Register (PCSR) */ sim.pit[pit_ch].pmr = clock_interval; tmp = pcsr_pre; tmp = (tmp << 8) | 0x0F; sim.pit[pit_ch].pcsr = tmp; }
12
Example Program (cont) /* -------------------------------------------------------------------------- UserMain -------------------------------------------------------------------------- */ void UserMain(void * pd) { InitializeStack(); if (EthernetIP == 0) GetDHCPAddress(); OSChangePrio(MAIN_PRIO); EnableAutoUpdate(); /* wait 16200 counts & divide the cpu clock (66.355 MHz) by 4096 - this equals approximately one pitr event per second */ SetUpPITR(1, /* Use PIT channel 1 */ 16200, /* Wait 16200 clocks */ 11 /* Divide by 4096 - see table 19-3 */ ); iprintf("Application started\n"); while (1) { OSTimeDly(20); /* Wait approximately 5 sec */ iprintf("PIT count = %ld\r\n",pit_count); }
13
Interrupt Vector Table
14
Interrupt Vector Table (cont)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.