MOD5213: Max frequency of GPIO switching speed?
-
- Posts: 4
- Joined: Thu Jan 08, 2009 12:01 pm
MOD5213: Max frequency of GPIO switching speed?
The system clk frequency of the MOD5213 is 66 MHz. Why is then the frequency of a square wave signal generated on a GPIO pin is just 2.7 MHz. The code I used is:
#include "predef.h"
#include <basictypes.h> // Include for variable types
#include <serialpoll.h> // Use serial polled driver
#include <SerialUpdate.h> // Update flash via serial port
#include <..\MOD5213\system\sim5213.h> // 5213 structure
int main()
{
SimpleUart( 0, 115200 );
EnableSerialUpdate();
writestring(0, "This application does not use the RTOS\r\n");
sim.gpio.ddrta = 0x04; // pin 26 on MOD5213
while(1)
{
sim.gpio.portta = 0x04;
sim.gpio.portta = ~0x04;
}
#include "predef.h"
#include <basictypes.h> // Include for variable types
#include <serialpoll.h> // Use serial polled driver
#include <SerialUpdate.h> // Update flash via serial port
#include <..\MOD5213\system\sim5213.h> // 5213 structure
int main()
{
SimpleUart( 0, 115200 );
EnableSerialUpdate();
writestring(0, "This application does not use the RTOS\r\n");
sim.gpio.ddrta = 0x04; // pin 26 on MOD5213
while(1)
{
sim.gpio.portta = 0x04;
sim.gpio.portta = ~0x04;
}
Re: MOD5213: Max frequency of GPIO switching speed?
You'll need to look at the assembly code that was generated and add up the clock cycles of the instructions in your while loop. If there are 33 clock cycles, the pulse should occur every 3 MHz.
I think.
I think.
-
- Posts: 4
- Joined: Thu Jan 08, 2009 12:01 pm
Re: MOD5213: Max frequency of GPIO switching speed?
How can I view the assembly code?
Re: MOD5213: Max frequency of GPIO switching speed?
You can use m68k-elf-objdump.exe that is in the "nburn/gcc-m68k/bin" directory.
Go into the "Release" folder of your project. You should see a ".elf" file. run "m68k-elf-objdump -d" supplying the filename as an argument.
If this is your UserMain, it will produce a large file. Search for "<UserMain>:".
I imagine that the code produced looks something like
address : moveq #4, %d0 // put 4 in register d0
address+2 : moveb %d0, <storage_address> // put the contents of d0 into the memory location
address+4 : moveq #-5, %d0 // put 11 in register d0
address+6 : moveb %d0, <storage_address> // put the contents of d0 into the memory location
address+8 : bras address
Now, if I had a clue how many clock cycles each instruction took for your processor, I'd tell you. But I don't.
There's probably some reference manual lurking around...
Go into the "Release" folder of your project. You should see a ".elf" file. run "m68k-elf-objdump -d" supplying the filename as an argument.
If this is your UserMain, it will produce a large file. Search for "<UserMain>:".
I imagine that the code produced looks something like
address : moveq #4, %d0 // put 4 in register d0
address+2 : moveb %d0, <storage_address> // put the contents of d0 into the memory location
address+4 : moveq #-5, %d0 // put 11 in register d0
address+6 : moveb %d0, <storage_address> // put the contents of d0 into the memory location
address+8 : bras address
Now, if I had a clue how many clock cycles each instruction took for your processor, I'd tell you. But I don't.
There's probably some reference manual lurking around...
-
- Posts: 4
- Joined: Thu Jan 08, 2009 12:01 pm
Re: MOD5213: Max frequency of GPIO switching speed?
Thank you for the answer. It helped me a lot.
For the C code below:
---------------------------------
while(1)
{
sim.gpio.portta = 0x04;
sim.gpio.portta = 0x00;
}
---------------------------------
I got the next assembler code:
---------------------------------------------------------------------
ffc0417e: 7004 moveq #4,%d0
ffc04180: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
ffc04186: 4200 clrb %d0
ffc04188: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
ffc0418e: 7004 moveq #4,%d0
ffc04190: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
ffc04196: 4200 clrb %d0
ffc04198: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
ffc0419e: 60de bras ffc0417e <main+0x3e>
---------------------------------------------------------------------
The assembler code I got by m68k-elf-objdump.exe is very similar to code you gave. It contains some redundant element.
Why did the C compiler first write zero to register d0 and after that some constant value? Why didn't the compiler wrote
immediately that constant value to the register d0?
Can you help me about nesting an assembler code in C programm to get faster code.
I tried to find the number of clock cycles for each instructions and I find it in the reference manual. It can be downloaded from:
http://www.freescale.com/files/32bit/do ... 5213RM.pdf
The table which contains the needed data is from pages 80 to 86.
The problem is that there are no such instructions as moveb or bras. I suppose the programm m68k-elf-objdump.exe works with
different set of instructions than the reference manual do.
Thanks for your help!
For the C code below:
---------------------------------
while(1)
{
sim.gpio.portta = 0x04;
sim.gpio.portta = 0x00;
}
---------------------------------
I got the next assembler code:
---------------------------------------------------------------------
ffc0417e: 7004 moveq #4,%d0
ffc04180: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
ffc04186: 4200 clrb %d0
ffc04188: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
ffc0418e: 7004 moveq #4,%d0
ffc04190: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
ffc04196: 4200 clrb %d0
ffc04198: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
ffc0419e: 60de bras ffc0417e <main+0x3e>
---------------------------------------------------------------------
The assembler code I got by m68k-elf-objdump.exe is very similar to code you gave. It contains some redundant element.
Why did the C compiler first write zero to register d0 and after that some constant value? Why didn't the compiler wrote
immediately that constant value to the register d0?
Can you help me about nesting an assembler code in C programm to get faster code.
I tried to find the number of clock cycles for each instructions and I find it in the reference manual. It can be downloaded from:
http://www.freescale.com/files/32bit/do ... 5213RM.pdf
The table which contains the needed data is from pages 80 to 86.
The problem is that there are no such instructions as moveb or bras. I suppose the programm m68k-elf-objdump.exe works with
different set of instructions than the reference manual do.
Thanks for your help!
Re: MOD5213: Max frequency of GPIO switching speed?
This:
ffc0417e: 7004 moveq #4,%d0
ffc04180: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
ffc04186: 4200 clrb %d0
ffc04188: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
is indeed redundant with this:
ffc0418e: 7004 moveq #4,%d0
ffc04190: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
ffc04196: 4200 clrb %d0
ffc04198: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
I find it curious that the compiler generated it. "bras" is an option on "bra" (branch always). i believe the "s" has to do with the addressing mode for the destination address.
"moveb" is a "move" instruction for a byte of data.
I'll try later today to unsuppress the memories for embedding assembler. it's pretty easy, if i recall correctly.
ffc0417e: 7004 moveq #4,%d0
ffc04180: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
ffc04186: 4200 clrb %d0
ffc04188: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
is indeed redundant with this:
ffc0418e: 7004 moveq #4,%d0
ffc04190: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
ffc04196: 4200 clrb %d0
ffc04198: 13c0 4010 000e moveb %d0,4010000e <sim+0x10000e>
I find it curious that the compiler generated it. "bras" is an option on "bra" (branch always). i believe the "s" has to do with the addressing mode for the destination address.
"moveb" is a "move" instruction for a byte of data.
I'll try later today to unsuppress the memories for embedding assembler. it's pretty easy, if i recall correctly.
Re: MOD5213: Max frequency of GPIO switching speed?
By the way, in netburner's supplied documentation, in the FreescaleManuals directory, CFPRM.pdf is the programmers reference manual. I explains the instructions.
-
- Posts: 513
- Joined: Sat Apr 26, 2008 7:14 am
Re: MOD5213: Max frequency of GPIO switching speed?
Using assembly code is easy. See http://www.netburner.com/downloads/tech ... nguage.pdf
-
- Posts: 513
- Joined: Sat Apr 26, 2008 7:14 am
Re: MOD5213: Max frequency of GPIO switching speed?
The appnote in the previous post seems to skip the easy case of just adding asm code directly withing regular c functions. A quick search on the nburn directory for asm yields many examples, but here;s one from MOD5234\ioboard.cpp:
Code: Select all
////////////////////////////////////////////////////////////////////////////////
// OnModDev70 - This function tests to see whether the MOD-DEV-70 carrier
// board is being used, otherwise a MOD-DEV-100 is assumed by default. This is
// done by pulling a designated signal pin low and then reading back its state.
// Since the LEDs on the MOD-DEV-70 will naturally pull this pin high, it will
// read back in a high state. The MOD-DEV-100 leaves this pin unconnected, so
// it will remain low and read back in a low state.
//
BOOL OnModDev70( void )
{
if ( !bInitModDev70 )
{
asm(" nop"); // Added for detection in debug mode
sim.gpio.par_uart &= ~0x0030; // Configure pin J2-23 for GPIO function
sim.gpio.pclrr_uartl = ~0x40; // Set J2-23 low
sim.gpio.pddr_uartl |= 0x40; // Configure J2-23 as an output
//
// Short delay to ensure J2-23 is pulled low.
//
for ( volatile int i = 0; i < 4000000; i++ ) asm(" nop");
sim.gpio.pddr_uartl &= ~0x40; // Configure J2-23 as an input
asm(" nop"); // Short delay to allow pin to pull up
asm(" nop");
//
// If J2-23 was pulled up, then the carrier board mounted onto is a
// MOD-DEV-70.
//
if ( sim.gpio.ppdsdr_uartl & 0x40 )
{
eTPUInit(); // Initialize eTPU pins for GPIO
bIsModDev70 = TRUE;
}
else
{
bIsModDev70 = FALSE;
}
bInitModDev70 = TRUE; // Confirm initialization of this condition
}
return bIsModDev70;
}
-
- Posts: 4
- Joined: Thu Jan 08, 2009 12:01 pm
Re: MOD5213: Max frequency of GPIO switching speed?
I'm very grateful for your help. I have just one more question:
Is it possible to concatenate these two instructions
moveq #4,%d0
moveb %d0,4010000e
into one instruction:
moveb #4,4010000e?
Is it possible to concatenate these two instructions
moveq #4,%d0
moveb %d0,4010000e
into one instruction:
moveb #4,4010000e?