Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Please help me-switch didn't function

Status
Not open for further replies.

Hidayah

Newbie level 2
Joined
Jan 25, 2008
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,319
Hi,

My program have no error but the switch doesn't work. Can someone please tell me what's wrong with my program ? Thanks.


Here is the original program, the swtich works.

#include <dsk5416.h>

void main()
{
int i;
//initialization here
DSK5416_init();
DSK5416_LED_init();
DSK5416_DIP_init();

while(1)
{
//body here
for(i=0;i<4;i++){
if (DSK5416_DIP_get(i) == 1)

//DIP switch(i) is on & LED(i) is on
DSK5416_LED_off(i);



else
//DIP switch(i) is off & LED(i) is off
DSK5416_LED_on(i);
}//for
}//while
}//main


But when I modified it, the switch didn't function. But no error. Please help me. Below is my program.Thanks.

#include <dsk5416.h>
#define GPIOCR (*(volatile unsigned int*)(0x3C))
#define GPIOCR_ADDR 0x3C
#define GPIOSR (*(volatile unsigned int*)(0x3D))
#define GPIOSR_ADDR 0x3D

void delay(void)
{

long i, j=0;
for(i=0;i<1000000;i++)
{
j++;
}

}


void main()
{

DSK5416_init();
DSK5416_LED_init();
DSK5416_DIP_init();

GPIOCR=0xff;

while(1)
{


if (DSK5416_DIP_get(1) == 1)
{
//=================================================================================
//DIP switch 1 is on & motor move


GPIOSR=0x01;
delay();
GPIOSR=0x02;
delay();
GPIOSR=0x04;
delay();
GPIOSR=0x08;
delay();


}
else if (DSK5416_DIP_get(2) == 1)
{
//=================================================================================
//DIP switch 2 is on & motor stop

GPIOSR=0x00;


}
else if (DSK5416_DIP_get(3) == 1)
{
//=================================================================================
//DIP switch 3 is on & motor move to the right


GPIOSR=0x08;
delay();
GPIOSR=0x04;
delay();
GPIOSR=0x02;
delay();
GPIOSR=0x01;
delay();

DSK5416_LED_off(3);

}
else
{

(DSK5416_DIP_get(4) == 1);

//=================================================================================
//DIP switch 4 is on & motor move to the left


GPIOSR=0x01;
delay();
GPIOSR=0x02;
delay();
GPIOSR=0x04;
delay();
GPIOSR=0x08;
delay();

DSK5416_LED_off(4);

}

}

}





Regards,
Dayah
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top