turing LEDs ON and OFF according the switches in MOD-DEV-70CR
Posted: Sun Aug 05, 2018 5:19 am
Hi again,
I use the MOD DEV 70CR with the MOD5441x module and I wanted to make a simple program that will use the switches and the LEDs.
to turn the corresponding switch's LED according to the switch state.
this is my code:
I took the StartAD() function form the factory demo program in the samples.
void UserMain(void * pd)
{
int i;
const BYTE PinNumber[8] = { 7, 6, 5, 3, 4, 1, 0, 2 }; // map J2 conn signals pins to A/D number 0-7
const BYTE LedNumber[8] = { 15, 16, 31, 23, 37, 19, 20, 24 };
InitializeStack();
GetDHCPAddressIfNecessary();
OSChangePrio(MAIN_PRIO);
EnableAutoUpdate();
iprintf("Running Rapid GPIO example on Pin J2-37\r\n");
SetupRGPIO();
J2[15] = 1; // OFF
InitSingleEndAD();
while (1)
{
StartAD();
while( !ADDone() ) asm("nop");
for(i=0;i<8;i++)
{
if ( GetADResult(PinNumber) > ( 0x7FFF / 2) )
J2[LedNumber] = 0;
else
J2[LedNumber] = 1;
}
}
}
switch 1 does not affect... and for some reason its corresponding LED is always OFF...
switch 4 does not affect too... and for some reason its corresponding LED is always ON...
switch 5 also does not affect and its correspondinf LED is always OFF.
switch 2,3,6,7,8 are also working fine.
what do I need to do in order to make switch 1,4 and 5 work?
and where can I find this info of how to configure the ports to work in the MOD DEV 70CR development kit?
thanks
I use the MOD DEV 70CR with the MOD5441x module and I wanted to make a simple program that will use the switches and the LEDs.
to turn the corresponding switch's LED according to the switch state.
this is my code:
I took the StartAD() function form the factory demo program in the samples.
void UserMain(void * pd)
{
int i;
const BYTE PinNumber[8] = { 7, 6, 5, 3, 4, 1, 0, 2 }; // map J2 conn signals pins to A/D number 0-7
const BYTE LedNumber[8] = { 15, 16, 31, 23, 37, 19, 20, 24 };
InitializeStack();
GetDHCPAddressIfNecessary();
OSChangePrio(MAIN_PRIO);
EnableAutoUpdate();
iprintf("Running Rapid GPIO example on Pin J2-37\r\n");
SetupRGPIO();
J2[15] = 1; // OFF
InitSingleEndAD();
while (1)
{
StartAD();
while( !ADDone() ) asm("nop");
for(i=0;i<8;i++)
{
if ( GetADResult(PinNumber) > ( 0x7FFF / 2) )
J2[LedNumber] = 0;
else
J2[LedNumber] = 1;
}
}
}
switch 1 does not affect... and for some reason its corresponding LED is always OFF...
switch 4 does not affect too... and for some reason its corresponding LED is always ON...
switch 5 also does not affect and its correspondinf LED is always OFF.
switch 2,3,6,7,8 are also working fine.
what do I need to do in order to make switch 1,4 and 5 work?
and where can I find this info of how to configure the ports to work in the MOD DEV 70CR development kit?
thanks