第4篇-DSP28069外设初始化1

一、CPU定时器初始化

/*************************************************************************/
/*  Name  : InitCpuTimers                                                */
/*                         	                                             */
/*  Init CPU Timers               										 */
/*                                                                       */
/*  In    : none				   										 */
/*  Out   : none                                                         */
/*  Return: none                                                         */
/*************************************************************************/
void InitCpuTimers(void)
{
 	// CPU Timer 0 not used

	// CPU Timer 1 为系统提供时基 执行测速程序  
	// Initialize address pointers to respective timer registers:
	CpuTimer1.RegsAddr = &CpuTimer1Regs;
	// Initialize timer period
	CpuTimer1Regs.PRD.all = CPUTIME1_PRD;	//90M/8K
	// Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
	CpuTimer1Regs.TPR.all = 0;
	CpuTimer1Regs.TPRH.all = 0;
	// Make sure timers are stopped:
	CpuTimer1Regs.TCR.bit.TSS = 1;
	// Reload all counter register with period value:
	CpuTimer1Regs.TCR.bit.TRB = 1;
	// CPU-Timer Emulation Mode  --Free run
	CpuTimer1Regs.TCR.bit.FREE = 0x3;
	// CPU-Timer Interrupt Enable
	CpuTimer1Regs.TCR.bit.TIE = 1;
	CpuTimer1Regs.TCR.bit.TSS = 0;
	// Reset interrupt counters:
	CpuTimer1.InterruptCount = 0;

	// CPU Timer 2  提供1ms时基
	CpuTimer2.RegsAddr = &CpuTimer2Regs;
	CpuTimer2Regs.PRD.all = CPUTIME2_PRD;	//90M/1K
	CpuTimer2Regs.TPR.all = 0;
	CpuTimer2Regs.TPRH.all = 0;
	CpuTimer2Regs.TCR.bit.TSS = 1;
	CpuTimer2Regs.TCR.bit.TRB = 1;
	CpuTimer2Regs.TCR.bit.FREE = 0x3;
	CpuTimer2Regs.TCR.bit.TIE = 1;
	CpuTimer2Regs.TCR.bit.TSS = 0;
	CpuTimer2.InterruptCount = 0;
}

- 仅初始化定时器1和定时器2,若使用定时器0,类似;

- 定时器1提供125us/8k时基,定时器2提供1ms/1k时基;

- 装载值分别为

//定时器频率
#define CPUTIME1_FRE  8000   //定时器1 频率  8K
#define CPUTIME1_PRD  SYS_FRE/CPUTIME1_FRE

#define CPUTIME2_FRE  1000   //定时器1 频率  1K
#define CPUTIME2_PRD  SYS_FRE/CPUTIME2_FRE

二、ADC初始化

/*************************************************************************/
/*  Name  : Init Adc                                                  	 */
/*                                                                       */
/*  Init ADC										                     */
/*                                                                       */
/*  In    : none                                                         */
/*  Out   : none                                                         */
/*  Return: none                                                         */
/*************************************************************************/
void InitAdc(void)
{
    //extern voi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

软件攻城狮阿三

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值