1 / 15

Programmable Interrupt Timer Modules PIT0, PIT1, PIT2, PIT3

Programmable Interrupt Timer Modules PIT0, PIT1, PIT2, PIT3. Memory Map. Status Register. Status Register Prescaler Field. Status Register Control / Status Fields. Modulus Register. Count Register. Functional Operation.

oshin
Download Presentation

Programmable Interrupt Timer Modules PIT0, PIT1, PIT2, PIT3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programmable Interrupt Timer ModulesPIT0, 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. /* ----------------------------------------------------------------------------- This example program exercises the Programmable Interval Timer in the 5282 CPU ----------------------------------------------------------------------------- */ #include "predef.h" #include <stdio.h> #include <ctype.h> #include <startnet.h> #include <autoupdate.h> #include <dhcpclient.h> #include <..\mod5282\system\sim5282.h> #include <cfinter.h> #include <utils.h> /* ----- 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; Example Program

  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<1) || (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)

  15. Interrupt Vector Table (cont)

More Related