configure.c

来自「dsp2812平台下的例程」· C语言 代码 · 共 67 行

C
67
字号
#include "DSP28_Device.h"


unsigned long temp;


void ConfigureCputimer(void)
{
	//设置cputimer0,使其20ms产生一个中断
	
	CpuTimer0.CPUFreqInMHz = 150;
	CpuTimer0.PeriodInUSec = 20000;
	temp = (long)CpuTimer0.CPUFreqInMHz*CpuTimer0.PeriodInUSec;
	CpuTimer0.RegsAddr->PRD.all = temp;
	CpuTimer0.RegsAddr->TPR.all = 0;
	CpuTimer0.RegsAddr->TPRH.all = 0;
	
	CpuTimer0.RegsAddr->TCR.bit.POL = 0;      // 0 = Pulse Low
	CpuTimer0.RegsAddr->TCR.bit.TOG = 0;     // 0 = No Toggle, POL bit defines action
	CpuTimer0.RegsAddr->TCR.bit.TSS = 1;      // 1 = Stop timer, 0 = Start/Restart Timer 
	CpuTimer0.RegsAddr->TCR.bit.TRB = 1;      // 1 = reload timer
	CpuTimer0.RegsAddr->TCR.bit.FRCEN = 0;    // Force output enable (not used)
	CpuTimer0.RegsAddr->TCR.bit.PWIDTH = 7;   // 7+1 = 8 SYSCLKOUT cycle pulse width 
	CpuTimer0.RegsAddr->TCR.bit.SOFT = 1;
	CpuTimer0.RegsAddr->TCR.bit.FREE = 1;     // Timer Free Run
	CpuTimer0.RegsAddr->TCR.bit.TIE = 1;      // 0 = Disable/ 1 = Enable Timer Interrupt
	
	// Reset interrupt counter:
	CpuTimer0.InterruptCount = 0;
	
	
}

void Setport(void)

{
/*------    设置键盘输出, 配置为GPIO  ---------*/
	EALLOW;
	GpioMuxRegs.GPBMUX.bit.C4TRIP_GPIOB13 = 0;
	GpioMuxRegs.GPBMUX.bit.C5TRIP_GPIOB14 = 0;
	GpioMuxRegs.GPBMUX.bit.C6TRIP_GPIOB15 = 0;
	
	GpioMuxRegs.GPBDIR.bit.GPIOB13 = 1;
	GpioMuxRegs.GPBDIR.bit.GPIOB14 = 1;
	GpioMuxRegs.GPBDIR.bit.GPIOB15 = 1;
	EDIS;

/*------	设置键盘输入,配置为GPIO   ---------*/

	
	//使能捕获功能引脚
    EALLOW;
    GpioMuxRegs.GPAMUX.bit.CAP1Q1_GPIOA8 = 0;
    GpioMuxRegs.GPAMUX.bit.CAP2Q2_GPIOA9 = 0;
    GpioMuxRegs.GPAMUX.bit.CAP3QI1_GPIOA10 = 0;
    
    GpioMuxRegs.GPADIR.bit.GPIOA8 = 0;
    GpioMuxRegs.GPADIR.bit.GPIOA9 = 0;
    GpioMuxRegs.GPADIR.bit.GPIOA10 = 0;
    EDIS;

}




⌨️ 快捷键说明

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