本帖最后由 huangfeng33 于 2014-10-10 14:05 编辑
#include <cstdio> //C语言可以用stdio.h
#include <cstring>//C语言可以用string.h
#include "C5402DEF.h"//DSP菜鸟HotPower创建
#include "class.h"
#define CCSdebug 1//1--IO模拟SPI; 0--硬件McBSP模块
extern "C" interrupt void Timer0Isr();//注意加extern "C"
extern "C" interrupt void Timer1Isr();
extern "C" interrupt void Eint0Isr();
extern "C" interrupt void Eint1Isr();
extern "C" interrupt void Eint2Isr();
extern "C" interrupt void Eint3Isr();
<div>SystemObjSystemObj(void)
{
Disable();//关中断
SREG->IMR = 0x0000;//
SREG->IFR = 0xffff;//清除
//设置0x0080为中断向量表首址,在第2个128页内。
SREG->PMST = (0x01 << PMST_IPTR) | (1 << PMST_MP_MC) | (1 << PMST_OVLY);
// SREG->PMST |= (1 << PMST_DROM);//数据可const. </div>
/*---------------------------------------------------------------------------
若:设置0x0100为中断向量表首址,在第3个128页内。
则:*.cmd文件应该改为:
PAGE 0: VECS: origin=0x0100, length=0x66
则:
SREG->PMST = (0x02 << PMST_IPTR) | (1 << PMST_MP_MC) | (1 << PMST_OVLY);
----------------------------------------------------------------------------*/
SystemInit();//系统初始化
}
void SystemObjSystemInit(void)
{
PllInit();//PLL初始化
TIMER0Init();
TIMER1Init();
EintInit();
/*--------------------------------------------------------
注意以下2个变量的作用域的不同
--------------------------------------------------------*/
if (SystemRamTest != 0x55aa) {//全局变量SystemRamTest
SystemRamTest = 0x55aa;//改写全局变量
}
if (SystemRamTest != 0x55aa) {//类成员变量SystemRamTest
SystemRamTest = 0x55aa;//改写类成员变量
}
IOXF = 0;
}
void SystemObjPllInit(void)
{
volatile unsigned int start;
SREG->SWWSR = 0x2000;
do {
SREG->CLKMD = 0;
__nop();
}
while(SREG->CLKMD & (1 << CLKMD_PLLSTATUS));
// SREG->CLKMD = (0 << CLKMD_PLLMUL) | (30 << CLKMD_PLLCOUNT) | (1 << CLKMD_PLLONOFF) | (1 << CLKMD_PLLNDIV) | (1 << CLKMD_PLLSTATUS);//10M
SREG->CLKMD = (9 << CLKMD_PLLMUL) | (30 << CLKMD_PLLCOUNT) | (1 << CLKMD_PLLONOFF) | (1 << CLKMD_PLLNDIV) | (1 << CLKMD_PLLSTATUS);//100M
// SREG->CLKMD = (14 << CLKMD_PLLMUL) | (30 << CLKMD_PLLCOUNT) | (1 << CLKMD_PLLONOFF) | (1 << CLKMD_PLLNDIV) | (1 << CLKMD_PLLSTATUS);//150M
for (start = 0; start < 10000; start ++);//等待外设上电复位正常结束
}
void SystemObjTIMER0Init(void)
{
TIMER0->TCR = (1 << TCR_TSS);//关闭定时器0
TIMER0->PRD = 60000;//设置定时周期
TIMER0->TIM = 60000;//设置定时计数器
TIMER0->TCR &= ~(1 << TCR_TSS);//启动定时器0
SREG->IMR |= (1 << IMR_TINT0);//允许TINT0中断
}
void SystemObjTIMER1Init(void)
{
TIMER1->TCR = (1 << TCR_TSS);//关闭定时器1
TIMER1->PRD = 0xffff;//设置定时周期
TIMER1->TIM = 0xffff;//设置定时计数器
// TIMER1->TCR &= ~(1 << TCR_TSS);//启动定时器1
// SREG->IMR |= (1 << IMR_TINT1);//允许TINT1中断
}
void SystemObjEintInit(void)
{
SREG->IMR |= (1 << IMR_INT0);//允许INT0中断
SREG->IMR |= (1 << IMR_INT1);//允许INT1中断
SREG->IMR |= (1 << IMR_INT2);//允许INT2中断
SREG->IMR |= (1 << IMR_INT3);//允许INT3中断
}
LcdObjLcdObj(void)
{
LcdInit();
}
void LcdObjLcdSpiSetup(void)
{
#if (ccsdebug == 0) |