?? vsi_control.c
字號:
}
case 4:
{
if(Pixel)
LCDInfo=LCDInfo|0x08;
else
LCDInfo=LCDInfo&0xf7;
break;
}
case 5:
{
if(Pixel)
LCDInfo=LCDInfo|0x04;
else
LCDInfo=LCDInfo&0xfb;
break;
}
case 6:
{
if(Pixel)
LCDInfo=LCDInfo|0x02;
else
LCDInfo=LCDInfo&0xfd;
break;
}
case 7:
{
if(Pixel)
LCDInfo=LCDInfo|0x01;
else
LCDInfo=LCDInfo&0xfe;
break;
}
}
TempValue=40*PositionY+PositionX/8+0x3000;
OutLCDCmd(0X46);
WAIT_LCD_IDLE;
OutLCDData(TempValue&0xff);
WAIT_LCD_IDLE;
OutLCDData((TempValue>>8)&0xff);
WAIT_LCD_IDLE;
OutLCDCmd(0X4c);
WAIT_LCD_IDLE;
OutLCDCmd(0X42);
WAIT_LCD_IDLE;
OutLCDData(LCDInfo);
}
//-------------顯示一段直線-----------
void DisPlayLine(unsigned int StartX,unsigned int StartY,unsigned int Length,unsigned int Direction)
{
unsigned int i=0;
if(Direction)//X方向
{
if(Length>240||Length<=0)
Length=0;
for(i=0;i<Length;i++)
PutPixelLCD(StartX+i,StartY,1);
}
else //Y方向
{
if(Length>320||Length<=0)
Length=0;
for(i=0;i<Length;i++)
PutPixelLCD(StartX,StartY+i,1);
}
}
void Clear_Lcd()
{
ClearLCDLay1();
ClearLCDLay2();
DisPlayLine(0,0,240,1);
DisPlayLine(0,0,320,0);
DisPlayLine(0,319,240,1);
DisPlayLine(239,0,320,0);
DisPlayLine(0,40,240,1);
DisPlayLine(0,292,240,1);
DisPlayLine(64,0,40,0);
DisPlayLine(136,0,40,0);
DisPlayLine(0,1,240,1);
DisPlayLine(1,0,320,0);
DisPlayLine(0,318,240,1);
DisPlayLine(238,0,320,0);
DisPlayLine(0,40,240,1);
DisPlayLine(0,292,240,1);
DisPlayLine(64,0,40,0);
DisPlayLine(136,0,40,0);
}
void Display_KeyFrame(unsigned char Key)
{
unsigned int i=0,j=0;
unsigned int StartY=112+16;
unsigned int StartX=28;
unsigned int TempValue=0;
TempValue=StartX;
StartX=320-120-StartY;
StartY=TempValue;
for(j=0;j<16;j++)
{
TempValue=40*StartY+(StartX+8*j)/8+0x3000;
OutLCDCmd(0X46);
WAIT_LCD_IDLE;
OutLCDData(TempValue&0xff);
WAIT_LCD_IDLE;
OutLCDData((TempValue>>8)&0xff);
WAIT_LCD_IDLE;
OutLCDCmd(0X4f);
WAIT_LCD_IDLE;
OutLCDCmd(0X42);
WAIT_LCD_IDLE;
for(i=0;i<192;i++)
OutLCDData(KEYBOARD[j+i*16]);
}
}
void main(void)
{
int i;
unsigned int key=0;
(*(char *)(lpstr+1))=0x7c;
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP281x_SysCtrl.c file.
InitSysCtrl();
// Step 2. Initalize GPIO:
// This example function is found in the DSP281x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
InitGpio(); // Skipped for this example
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;
// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP281x_PieCtrl.c file.
InitPieCtrl();
/*** Copy all FLASH sections that need to run from RAM ***/
// Section ramfuncs contains user defined code that runs from CSM secured RAM
/* memcpy( &ramfuncs_runstart,
&ramfuncs_loadstart,
&ramfuncs_loadend - &ramfuncs_loadstart);
*/
/*** Initialize the FLASH ***/
// InitFlash(); // Initialize the FLASH (FILE: SysCtrl.c)
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in DSP281x_DefaultIsr.c.
// This function is found in DSP281x_PieVect.c.
InitPieVectTable();
// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP281x_InitPeripherals.c
InitPeripherals();
// Step 5. User specific functions, Reassign vectors (optional), Enable Interrupts:
// Reassign ISRs.
// Reassign the PIE vector for T2UFPINT, CAPINT1 , NMI
// and T4PINT to point to a different
// ISR then the shell routine found in DSP28_DefaultIsr.c.
// This is done if the user does not want to use the shell ISR routine
// but instead wants to use their own ISR. This step is optional:
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.T2UFINT = &eva_t2ufint_isr;
PieVectTable.CAPINT1 = &eva_capint1_isr;
PieVectTable.CAPINT2 = &eva_capint2_isr;
PieVectTable.RXAINT = &sciarxint_isr;
PieVectTable.RXBINT = &scibrxint_isr;
PieVectTable.XNMI = &xnmi_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable PIE group 3 interrupt 3,5 for T2UFINT,CAPINT1
PieCtrlRegs.PIEIER3.all = (M_INT3 | M_INT5);
// Enable PIE group 9 interrupt 1,3 for SCIRXINTA, SCIRXINTB
PieCtrlRegs.PIEIER9.all = (M_INT1 | M_INT3);
// Enable CPU INT3 for T2UFINT, CAPINT1,INT9 for SCIRXINTA,SCIRXINTB:
IER |= (M_INT3 | M_INT9);
// Initialize user variable
initvariable();
//
//test
ch = (unsigned char)(*lpstr);
(*(char*)lpstr) = 0xf0;
WAIT_LCD_IDLE;
(*(char*)lpstr) = 0x08;
WAIT_LCD_IDLE;
(*(char*)lpstr) = 0xfc;
WAIT_LCD_IDLE;
(*(char *)(lpstr+1))=0x7c;
WAIT_LCD_IDLE;
(*(char *)(lpstr+1))=0x71;
WAIT_LCD_IDLE;
(*(char *)(lpstr+8))=0x00;
(*(char *)(lpstr+8))=0xFF;
WAIT_LCD_IDLE;
(*(char *)(lpstr+8))=0x55;
(*(char *)(lpstr+1))=0x6e;
WAIT_LCD_IDLE;
(*(char *)(lpstr+9))=0xFF;
WAIT_LCD_IDLE;
(*(char *)(lpstr+9))=0x00;
WAIT_LCD_IDLE;
(*(char *)(lpstr+1))=0x6c;
InitLCD1335();
Clear_Lcd();
Display_KeyFrame(0);
(*(char *)(lpstr+1))=0x6c;
while(1){
(*(char *)(lpstr+1))=0x2c;
(*(char *)(lpstr+1))=0xa8;
key = (*(char *)(lpstr+6));
(*(char *)(lpstr+1))=0x2c;
(*(char *)(lpstr+1))=0x6c;
if( (key &= 0xff) ) {
LCD_NOP;
// key = (*(char *)(lpstr+6));
LCD_NOP;
// break;
}
}
DisPlayLine(10,10,50,1);
DisPlayLine(20,20,50,0);
DisPlayLine(30,30,150,1);
// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
// Step 6. IDLE loop. Just sit and loop forever:
while(1)
{
/*
if(1)//SciaRegs.SCICTL2.bit.TXRDY == 1)
{
SciaRegs.SCITXBUF = 0xeb;
SciaRegs.SCITXBUF = 0x90;
SciaRegs.SCITXBUF = 0x0a;
SciaRegs.SCITXBUF = 0x0b;
SciaRegs.SCITXBUF = 0x0c;
}
if(ScibRegs.SCICTL2.bit.TXRDY == 1)
{
ScibRegs.SCITXBUF = 0x90;
}*/
if(CtrVars.reset_lock==1)
{
if(CtrVars.Udc_aver>CtrVars.Udc_uplimit)
{
CtrVars.Udc_high_fault=1;
CtrVars.fault=1;
}
else if(CtrVars.Udc_aver<CtrVars.Udc_lowlimit)
{
CtrVars.Udc_low_fault=1;
CtrVars.fault=1;
}
else if(CtrVars.Vs_sinwt_main>1250) // over voltage
{
CtrVars.Vs_fault=1;
CtrVars.fault=1;
}
else if(abs(CtrVars.Il>1900)) // overload or over-current
{
CtrVars.Il_fault=1;
CtrVars.fault=1;
}
else
{
CtrVars.pwm_enable=1;
}
}
if((CtrVars.pwm_enable==1)&&(CtrVars.fault==0))
{
if(CtrVars.run_stop==0)
{
CtrVars.pianci=0;
for(i=0;i<f_point;i++)CtrVars.rep[i]=0;
CtrVars.Vyk=0; CtrVars.Vyks1=0;/* reset some important variables */
CtrVars.pid_Vyks1=0; CtrVars.pid_Vyks2=0;
CtrVars.start=1; CtrVars.run_stop=1;
EvaRegs.CMPR1=pwm_half_per/2; EvaRegs.CMPR2=pwm_half_per/2;
EvaRegs.COMCONA.bit.FCOMPOE=1; /* enable PWM output */
// StatusLed(1); // light it
CtrVars.pianci_rec=0;
}
else
{
CtrVars.run_stop=0;
EvaRegs.COMCONA.bit.FCOMPOE=0; /* disable PWM output */
// StatusLed(0); // black out
//
}
}
else
{
EvaRegs.COMCONA.bit.FCOMPOE=0; /* disable PWM output */
if(CtrVars.run_stop==1)
{
CtrVars.fault=1;
CtrVars.run_stop=0;
} /* don't allow self-restart after detecting fault */
}
KickDog(); /* reset watchdog */
}; /* endless loop, wait for interrupt */
}
// Step 7. Insert all local Interrupt Service Routines (ISRs) and functions here:
// If local ISRs are used, reassign vector addresses in vector table as
// shown in Step 5
interrupt void eva_t2ufint_isr(void)
{
unsigned int CHA7 , CHA6 , CHA5 , CHA4;
int offset , temp , Vs_err , Vs_ref , pre_value , pid_output , N , sinN , cosN;
long temp_32 , temp32;
// Note: To be safe, use a mask value to write to the entire
// EVAIFRA register. Writing to one bit will cause a read-modify-write
// operation that may have the result of writing 1's to clear
// bits other then those intended.
EvaRegs.EVAIFRB.bit.T2UFINT = 1;
//led
/*
count++;
if(count >= 10000)
{
ch = (unsigned char)(*lpstr);
(*(char*)lpstr) = ~ch;
(*(char *)(lpstr+4))=ch;
ch = (unsigned char)(*(lpstr+2));
count=0;
}
*/
//--- calculate the phase angle-------------------------
offset=CtrVars.sum_counter/f_point;
CtrVars.sum_counter=CtrVars.sum_counter+512;
if(offset>=512)
{
offset=0;
}
CtrVars.sinwt=*(sintab_pointer+offset)>>16;
CtrVars.coswt=*(sintab_pointer+offset+128)>>16;
N=offset+8;
sinN=*(sintab_pointer+N)>>16;
cosN=*(sintab_pointer+offset+116)>>16;
//---- read the sample values-----------------------------
//Vs
CHA7 = AdcRegs.ADCRESULT0;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -