the rapid port example of MOD5441x
Posted: Wed Jul 25, 2018 5:10 am
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.
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.