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

📄 main.c

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

typedef struct	{ UINT8* base_pointer;
	  UINT32 Buffer_size;
	  UINT32 Current_index;
	} REC_BUF_TYPE	 ;

   UINT8 actual_buffer[100];
   REC_BUF_TYPE Rec_Buf;
   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 initSci() 
{
							// STEP 1: MODULE SPECIFIC INITIALIZATION
							// Initialize the SCI for simple operation
    QSMCM.SCC1R0.B.SC1BR = 40000000/32/9600;	// Set baud rate
    QSMCM.SCC1R1.B.TE = 1;	// Transmitter enable
    QSMCM.SCC1R1.B.RE = 1;	// Receiver enable
							// Initialize buffer variables
    Rec_Buf.Current_index =0;
    Rec_Buf.Buffer_size = 100;
    Rec_Buf.base_pointer = (UINT8 *)&actual_buffer ;

							// STEP 2: LEVEL ASSIGMENT
    QSMCM.QDSCI_IL.B.ILDSCI = 5;	// define SCIIRQ at level 5

							// STEP 3: ENABLE INTERRUPT
    QSMCM.SCC1R1.B.RIE = 1;	// Enable receive interrupts only

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

main()
{
   init555();				// Perform a simple 555 initialzation
   initSci();				// Iniialize SCI module 
   asm(" mtspr EIE, r3");	// FINAL STEP: SET MSR[EE], MSR[RI] BITS
   while(1)					// Wait for SCI interrupts	
   {
   		loopctr++;
   }			     
}



⌨️ 快捷键说明

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