the rapid port example of MOD5441x

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

the rapid port example of MOD5441x

Post by andiso »

hi,

we are using the MOD5441x module and want to make a simple program that toggle a port.

for this purpose we used the MOD5441x-RapidGPIO from the example folder.

we have this code:



=====================================================================
void UserMain(void * pd)
{
InitializeStack();
GetDHCPAddressIfNecessary();
OSChangePrio(MAIN_PRIO);
EnableAutoUpdate();

iprintf("Running Rapid GPIO example on Pin J2-37\r\n");

// Use pins class to toggle the signal slowly to help verify you are on
// the correct pin if you are trying to measure it with a oscilloscope.
J2[GPIO_PIN].function(GPIO_PIN_FUNCTION);
J2[GPIO_PIN] = 0;
J2[GPIO_PIN] = 1;
J2[GPIO_PIN] = 0;
J2[GPIO_PIN] = 1;
J2[GPIO_PIN] = 0;

SetupRGPIO();

while (1)
{
OSTimeDly( TICKS_PER_SECOND );
// Pulse50();
//Pulse50LoopAsm();
Pulse50LoopC();
}
}


===========================================================================

I commented the Pulse50()
and uncommented the Pulse50LoopC() function.


this is the Pulse50LoopC() function:


/*-------------------------------------------------------------------------------------------------
* Toggle the RGPIO signal 50 times using C code. Edge to edge timing should be about 94ns.
* ------------------------------------------------------------------------------------------------*/
void Pulse50LoopC()
{
volatile PWORD pRGPIO_BAR = (PWORD) RGPIO_BAR;

USER_ENTER_CRITICAL(); // Do not allow other task or interrupts

for ( int i = 0; i < 50; i++ )
{
// The following asm code sets the toggle register bit RGPIO 0
asm(" nop"); // Without this nop the cache will make the first pulse time vary
pRGPIO_BAR[RGPIO_TOG] = RGPIO_0;
}

USER_EXIT_CRITICAL();
}


as far as I familiar with embedded codes this kind of code should run endlessly...
but in our netburner this code runs for a few seconds and then one of the LED in the development kit turn ON.

what am I missing?

I also cant understand how this code is toggling a port on and off...

for example in other controllers like PIC of microchip if I want to toggle a port on and off I do something like this:

PORTBbits.RB0=1;
PORTBbits.RB0=0;

and I put this in an endless loop and thats it, the port start toggling...

is there any document that describe the C language of the netburner?

thanks in advanced for any help.
ecasey
Posts: 164
Joined: Sat Mar 26, 2011 9:34 pm

Re: the rapid port example of MOD5441x

Post by ecasey »

Why do you think it is not working? Do you have a scope on pin J2-37?
Pin J2-37 is connected to LED5 on the MOD-DEV-70 board, but you won't be able to see a 94 nanosecond pulse changing with your eye. it would probably look like it is on at half brightness.

If you want to see the toggle on the LED, you will have to slow it down a lot. Something like this:


for (int i = 0; i<50; i++){
J2[GPIO_PIN] = 0;
OSTimeDly(10);
J2[GPIO_PIN] = 1;
OSTimeDly(10);
}
andiso
Posts: 16
Joined: Tue Jul 24, 2018 6:28 am

Re: the rapid port example of MOD5441x

Post by andiso »

actualy I do have a scope on the J2_37 pin.

but the thing that is strange is that I can see LED5 light not half brightness but full brightness its just that PORT K=J2 37 is OFF for about 1 second and every 1 second it go HIGH for 500 nsec I see it in scope.

the only conclusion I can think of is that the logic is opposite?
that mean the LED is on when pin 37 is LOW? and OFF when its high?

is there any document that can teach me the C language?

thanks very much for your help :)
ecasey
Posts: 164
Joined: Sat Mar 26, 2011 9:34 pm

Re: the rapid port example of MOD5441x

Post by ecasey »

Scope has to be set to capture an edge and able to see 94ns wave. LED5 is off when Pin J2-27 is high - reverse logic. LED5 is also connected to Pin J2-15, so depending on how that pin is set, it could be interfering.

Lots of good stuff on the internet for learning C and C++.
Post Reply