MOD5213: Max frequency of GPIO switching speed?

Discussion to talk about software related topics only.
hendrixj
Posts: 33
Joined: Thu Oct 23, 2008 11:39 am

Re: MOD5213: Max frequency of GPIO switching speed?

Post by hendrixj »

i doubt there is a single instruction to do that, but i'm not very knowledgable about 68000 machine code.

Here is how to inline assembler code to do something like you want:

__asm__(
"$myloop:\n\t"
"moveq #1,%d0\n\t"
"moveb %d0,sim+0x10000e\n\t"
"clrb %d0\n\t"
"moveb %d0,sim+0x10000e\n\t"
"bras $myloop\n\t"
);

i suppose you can tighten up the loop by setting 1 in d0 and 0 in d1:
__asm__(
"moveq #1,%d0\n\t"
"moveq #0,%d1\n\t"
"$myloop:\n\t"
"moveb %d0,sim+0x100012\n\t"
"moveb %d1,sim+0x100012\n\t"
"bras $myloop\n\t"
);
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: MOD5213: Max frequency of GPIO switching speed?

Post by lgitlitz »

I doubt you will ever be able to get more then 4 MHz or so. There are a few reasons for this. The assembly instructions to do this are going to be 4 consecutive move instructions. The Coldfire cores have a 2 cycle delay when doing consecutive moves, so this will be added on to what ever the move instruction time is. You are also moving 8-bit data into the GPIO registers which is slower then moving the native 32-bit bus size. The code is being fetched from FLASH which is a bit slower then the single cycle SRAM so it will take more then a clock cycle to load the instruction. The peripherals are also located on a separate bus then the CPU bus so there might be a delay cycle when talking through the bus arbitration.

The MOD5213 has a lot of excellent timers on board. You should be able to get a 33MHz clock when using the output pins of the DMA or GPT timers. There is also a PWM peripheral that should get very high switch speed. The pin you are trying to toggle at high frequency is already connected to the GPT timer. This will also use no CPU time once it is configured properly, where toggling a GPIO line uses 100% of the CPU time. I would use the peripherals whenever possible.

-Larry
hendrixj
Posts: 33
Joined: Thu Oct 23, 2008 11:39 am

Re: MOD5213: Max frequency of GPIO switching speed?

Post by hendrixj »

I'd be very interested in seeing what kind of response this would get you:


__asm__(
"lea sim+0x10000e,%a0\n\t" // put &sim.gpio.porta into A0
"Loop:"
"bchg #0,(%a0)\n\t" // Chage bit 0 of memory
"bras Loop\n\t"
);
Post Reply