DSP综合实验4 联系客服

发布时间 : 星期五 文章DSP综合实验4更新完毕开始阅读

portf000=0; motor=0x8; for(i=0;i<5;i++) {

for(j=0;j<11;j++) {

portf000=motor; /* send drive pluse to motor */ motor=motor >> 1;

for(k=0;k<2;k++) /* delay */ mydelay(); if(motor == 0x0) motor=0x8; } } }

void traffic_led() { int *imr_addr;

lcd_clr(1); /* clear LCD display */

mydelay();

lcd_printf(1,0,\正在演示交通灯..\ /* wait for send end ! */ mydelay();

lcd_printf(4,2,\键退出) \ /* wait for send end ! */ mydelay();

TimerIndex=0;

TimerNum=Led_Delay[0];//延时数组放有不同的昝常数

imr_addr=(int *)IMR_ADDR;

*imr_addr |= 0x8; /* enable INT0 ! *///开启定时器

while( (get_key(1) & 0xff) != 59);//

imr_addr=(int *)IMR_ADDR;

*imr_addr &= 0xfff7; /* disable INT0 ! *///关闭

portc000=0; /* close all LED */ }

void interrupt show_traffic_led()

{

portc000=Led_Traffic[TimerIndex];//Led_Traffic[]数组放有不同的交通灯显示状态 TimerNum--;

if(TimerNum ==0 )

{ TimerIndex++;

if(TimerIndex == 24) TimerIndex=0;

TimerNum=Led_Delay[TimerIndex]; } } void test_led() { int led=0,i=0,j=0;

for(i=0;i<5;i++) /* all LEDs flash 5 times */ {

portc000=0; mydelay(); portc000=0xffff; mydelay(); }

for(j=0;j<5;j++) /* LEDs bright one by one */ {

portc000=0; /* shut down all led ! */ led=1;

for(i=0;i<16;i++) {

portc000=led; /* bright one LED */ mydelay(); /* delay 0.5 s */ portc000=0; led=led << 1; } }

for(i=0;i<5;i++) /* flash all again */ {

portc000=0; mydelay();

portc000=0xffff; mydelay(); }

portc000=0; /* close all LEDs */ }

void led() { int i;

lcd_clr(1); /* clear LCD display */

mydelay();

i=lcd_printf(1,0,\正在测试交通灯\ /* wait for send end ! */ mydelay();

i=lcd_printf(2,0,\请稍候. . . \ /* wait for send end ! */ test_led(); /* flash the 16s led one by one */

i=lcd_printf(4,2,\测试完毕!\ /* wait for send end ! */ for(i=0;i<5;i++) mydelay(); }

void step_motor() { int i;

lcd_clr(1); /* clear LCD display */ mydelay();

i=lcd_printf(1,0,\正在测试步进电机\ /* wait for send end ! */ mydelay();

i=lcd_printf(2,0,\请稍候. . . \ /* wait for send end ! */ mydelay();

test_stepmotor(); /* drive stepmotor run */

i=lcd_printf(4,2,\测试完毕!\ /* wait for send end ! */ for(i=0;i<5;i++) mydelay(); }

void dc_motor() { int i;

lcd_clr(1); /* clear LCD display */

mydelay();

i=lcd_printf(1,0,\正在测试直流电机\ /* wait for send end ! */ mydelay();

i=lcd_printf(2,0,\请稍候. . . \ /* wait for send end ! */ mydelay();

test_DCmotor(); /* drive DC motor to run */

i=lcd_printf(4,2,\测试完毕!\ /* wait for send end ! */

for(i=0;i<5;i++) mydelay(); }

void ram() { int i;

for(i=0;i<2;i++) mydelay();

lcd_clr(1); /* clear LCD display */

mydelay();

i=lcd_printf(1,0,\正在测试存储器,\ /* wait for send end ! */ mydelay();

i=lcd_printf(2,0,\请稍候. . . \ /* wait for send end ! */

mydelay();

i=test_mem(1);//i=chk_prog18000(); if(i == 1)

lcd_printf(2,0,\程序18000h..正确\ else

lcd_printf(2,0,\程序18000h..有错\ error_sound(i);

i=chk_prog28000(); /* test ext_sram ok? PROG-28000h */ /* if return=1, then ext_sram ok ! */ if(i == 1)

lcd_printf(3,0,\程序28000h..正确\ else

lcd_printf(3,0,\程序28000h..有错\

error_sound(i);

/* if ok, one shot sound, then two long sound */

/* if ok, one shot sound, then two long sound */

/* test ext_sram ok? PROG-18000h */

/* if return=1, then ext_sram ok ! */

i=chk_data8000();//i=test_mem(3); /* test ext_sram ok ? data-8000h */ if(i == 1)

lcd_printf(4,0,\数据8000h...正确\ else

lcd_printf(4,0,\数据8000h...有错\

error_sound(i);

/* if ok, one shot sound, then two long sound */