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

📄 arch_arm.c

📁 提高μCOS-II在ARM上执行效率的几种方法》相应代码
💻 C
字号:
#include "..\..\ucosii\ucos_ii.h"
#include "2410addr.h"
#include "clock.h"
#include "LEDTest.h"
#include "UART.h"
#include "arch_arm.h"

extern void __irq OSTickISR(void);
extern void __irq EInt0Isr(void);

extern OS_EVENT  * mysem;


void TimerStart()
{
	/* init int for timer */
    pISR_TIMER0=(unsigned)OSTickISR;	
    rINTMSK &=~(BIT_TIMER0);   /*enable timer mask */

	/* init timer */

	/* Dead zone length = 0; Prescaler1 = 0; Prescaler0(for time 1 and time 0) = 255 */
	rTCFG0  = (rTCFG0  & ~(0xFF))|0xFF;

	/* DMA mode = No select(0); MUX4 to MUX1 for Clock divide = 0; MUX0 = 1/16(0011B) */
	rTCFG1  = (rTCFG1  & ~(0xF))|0x3;

	/* Timer 0 compare buffer register */
	rTCMPB0 = 0;

	/* Timer 0 count buffer register */
	rTCNTB0 = 310;							/* 25ms */

	/* Dead zone enalbe = 0; Timer0 auto reload = 1; Timer0 output inverter = 0(off);
	  Timer 0 manula updata = 1; timer 0 start = 0; */
	rTCON  = (rTCON  & ~(0xF))|0xA;

	/* clear manual updata and start timer */
	rTCON  = (rTCON  & ~(0xF))|0x9;
}

void TimerEnd()
{
	/* set timer 0 start = 0 */
	rTCON  = (rTCON  & ~(0xF))|0x8;
}
void IntInit()
{
	/* int init */
    rINTMOD=0x0;			/* All=IRQ mode  */
    rINTMSK=BIT_ALLMSK;		/* All interrupt is masked. */
}

void EInt0Init()
{
    // 设置中断屏蔽位:
    rINTMSK &= ~(BIT_EINT0);  
    
    // 设置中断服务程序:
    pISR_EINT0 = (unsigned)EInt0Isr;
    
    //设置IO端口为第二功能
	//设置EINT2和EINT0对应的标志位为10。设置为上拉。
    //*** PORT F GROUP
    //Ports  : GPF7   GPF6   GPF5   GPF4      GPF3     GPF2  GPF1   GPF0
    //Signal : nLED_8 nLED_4 nLED_2 nLED_1 nIRQ_PCMCIA EINT2 KBDINT EINT0
    //Setting: Output Output Output Output    EINT3    EINT2 EINT1  EINT0
    //Binary :  01      01 ,  01     01  ,     10       10  , 10     10
    rGPFCON = (rGPFCON & ~(0xF))|0x2;
    rGPFUP  = (rGPFUP  & ~(0xF))|0x0;         

    //设置EXINT0. 10B:表示下降沿触发中断,低电平有效。
    rEXTINT0  = (rEXTINT0  & ~(0xF))|0x02;    

}
void CntTimerInt()
{

	/* init timer */

	/* Dead zone length = 0; Prescaler1 = 0; Prescaler0(for time 1 and time 0) = 255 */
	rTCFG0 = 0x0000;

	/* DMA mode = No select(0); MUX4 to MUX1 for Clock divide = 0; MUX0 = 1/16(0011B) */
	rTCFG1  = 0x000;

	/* Timer 0 compare buffer register */
	rTCMPB2 = 0;

	/* Timer 0 count buffer register */
	rTCNTB2 = 0xFFFF;

	/* Dead zone enalbe = 0; Timer0 auto reload = 1; Timer0 output inverter = 0(off);
	  Timer 0 manula updata = 1; timer 0 start = 0; */
	rTCON  = 0xA000;
}

/* init system related parameter. eg.:uart memory */
void SysInit()
{
	/* 2410 clock init */
    ChangeClockDivider(1,1);		/* 1:2:4  */
    ChangeMPllValue(161,3,1);		/* FCLK=202.8Mhz */

	IntInit();

	Led_Init();

	Led_Display(0xF);
	
	EInt0Init();
	CntTimerInt();

	Uart_Init(0,115200);
}

⌨️ 快捷键说明

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