⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 mpc564 时钟中断 时钟中断
💻 C
字号:
#include "mpc555.h"

   UINT32 counter = 0 ;		// Global for ISR to hold the 
   							// number of PIT interrupts
   UINT32 loopctr = 0 ;		// Loop counter for main loop

void init555()				// Simple MPC555 Initialization
{
   USIU.SYPCR.R = 0xffffff03; // Disable watchdog timer 
   USIU.PLPRCR.B.MF = 0x009; // Run at 40MHz for 4MHz crystal
   while(USIU.PLPRCR.B.SPLS == 0);	// Wait for PLL to lock	
   UIMB.UMCR.B.HSPEED = 0;	// Run IMB at full clock speed				       
}


void initPIT() 
{
							// STEP 1: MODULE SPECIFIC INITIALIZATION
   USIU.PITC.B.PITC = 1000;	// Setup count value.
   USIU.PISCR.B.PITF = 1;	// Freeze enabled to stop PIT
   USIU.PISCR.B.PTE = 1;	// PIT enabled to start counting	  
   
							// STEP 2: LEVEL ASSIGNMENT
   USIU.PISCR.B.PIRQ = 0x80; // Level 0 PIT interrupt

							// STEP 3: ENABLE INTERRUPT
   USIU.PISCR.B.PIE = 1 ;	// Enable PIT interrupt

							// STEP 4: SET APPROPRIATE SIMASK BITS
   USIU.SIMASK.R = 0x40000000; 	// Enable level 0; others disabled
} 


main()
{
	init555();				// Perform a simple 555 initialization
	initPIT();				// Init PIT to generate interrupts
  	asm(" mtspr EIE, r3");	// FINAL STEP: SET MSR[EE], MSR[RI] BITS
   	while(1)					// Wait for PIT interrupts	
   	{
   	loopctr++;				// Increment loopctr for something to do
   	}			     
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -