Fast System Clock

Hello,

I’m using a 16mHz clock and want to make my board as fast as possible. With the code below I toggle a pin continuously and the maximum frequency I can get is 4.1mHz What am I doing wrong??

void main()

{

PLLCON = 0x03; //Activate PLL connect and PLL enable

PLLCFG = 0x09; //Multiply clk by 10

PLLFEED = 0xAA; //Activate

PLLFEED = 0x55; //Activate

VPBDIV=0x01;

MAMCR=2;

MAMTIM=3;

while(1)

{IO1SET=0x70000;

IO1CLR=0x70000;

}

}

ARM I/O is rather slow, you won’t get more than 4 MHz on the older chips. The newer ones are much faster.

Leon

According to the user manual for the LPC2148, which has fast IO, the fastest you can change IO is around 15.4 MHz when the internal bus is running at 60 MHz (p. 94). The slow IO ports change around 3.5 times slower, and can change at 4.25 MHz. If you’re going for speed, you should definitely step up to one of the better chips (213x or 214x).

I too am new to ARM uCs. What bit of information did you use to discern which processor he is using? I don’t see it anywhere in his post.

I don’t know what processor he’s using, I was just saying the thing about the LPC2148 as an example. He may be using an ARM with fast I/O and the slow speed is all that C will allow. The example in the user manual uses assembly for maximum speed. I was basically just trying to illustrate leon_heller’s point about how slow the I/O is in certain ARMs.

It’s true that I’m using a LPC2148. Has anyone a simple test program in which they initialize fast io and toggle pins at 15mhz? I can’t do it…

I’m back again,

The fastest speed I can get now is 8mHz. But I want to get the 16mHz, what do I have to change or can I change in the program beneath?

void main()

{ PINSEL1=0x00;

SCS=0x02; //Enable Mask Register

PLLCFG = 0x09; //Multiply clk by 10

PLLFEED = 0xAA; //Activate

PLLFEED = 0x55; //Activate

PLLCON = 0x01; //Activate PLL connect and PLL enable

PLLFEED = 0xAA; //Activate

PLLFEED = 0x55; //Activate

while(!(PLLSTAT & 0x400)) ; // Wait until PLL Locked

PLLCON = 0x03; //Activate PLL connect and PLL enable

PLLFEED = 0xAA; //Activate

PLLFEED = 0x55; //Activate

FIO1DIR = 0x70000;

FIO1MASK = 0x0000;

while(1)

{/* Make pin 1.16, 1.17, 1.18 High*/

FIO1SET=0x70000;

/* Make pin 1.16, 1.17, 1.18 Low*/

FIO1CLR=0x70000;

}

}

Set the SCS register to 0x03. Take a look at p. 26 in the user manual and you will see that you have to have both bits set to get both of the I/O registers to work with fast I/O (FIO0 and FIO1). This may not fix your problem depending on which register you’re using. If you want to get the 15 MHz switching speed, you’re more than likely going to have to use assembly. Check out the page in the user manual that I referenced in a previous post and it shows the assembly they used to do it.