turing LEDs ON and OFF according the switches in MOD-DEV-70CR

Discussion to talk about software related topics only.
Post Reply
andiso
Posts: 16
Joined: Tue Jul 24, 2018 6:28 am

turing LEDs ON and OFF according the switches in MOD-DEV-70CR

Post by andiso »

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
User avatar
Jon
Posts: 79
Joined: Mon Feb 05, 2018 10:54 am

Re: turing LEDs ON and OFF according the switches in MOD-DEV-70CR

Post by Jon »

Hi Andiso,

I'm not sure if this is exactly the problem (I haven't tried to build your project), but it looks like you're trying to use the PinNumber and LedNumber arrays in your for loop from UserMain() without providing the index to them. I'm guessing you want to use i, but again, haven't built your project to test it myself.

One other quick observation, the Factory App for the MOD54415 that I'm looking at doesn't include the function SetupRGPIO(). Did you pull that from somewhere else? I would check in there and make sure it's actually doing what you want it to do. The corresponding code to set the J2 pins to GPIO mode for the Factory App that I'm looking at is found in WriteLeds( BYTE LedMask ), in webfuncs.cpp.

In that first if statement, you can see it runs a for loop that calls:

J2[PinNumber].function( PIN_GPIO );

I hope this helps get you started.

Kind Regards,
Jon
andiso
Posts: 16
Joined: Tue Jul 24, 2018 6:28 am

Re: turing LEDs ON and OFF according the switches in MOD-DEV-70CR

Post by andiso »

thanks this
J2[PinNumber].function( PIN_GPIO );

solved it
User avatar
Jon
Posts: 79
Joined: Mon Feb 05, 2018 10:54 am

Re: turing LEDs ON and OFF according the switches in MOD-DEV-70CR

Post by Jon »

Glad that helped. =)
Post Reply