Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

Different execution speed between simulator and chip (LDRB, STRB instructions).

Different execution speed between simulator and chip (LDRB, STRB instructions).

2005-09-26 by conhalk

Hello,

I am using the lpc2138, and I have wrote a program which includes 
reading port0.16-24 pins at a 10 Mhz sampling rate:

                            // R6 contains port.26-24 address
LDRB R7,[R6,#0x00000002]    // R5 contains the memory address 
STRB R7,[R5,#0x00000000]!   // to store the input(auto-increments)
NOP			    // R7 is temporary storage	
LDRB R7,[R6,#0x00000002]
STRB R7,[R5,#0x00000001]!
NOP			
LDRB R7,[R6,#0x00000002]		
STRB R7,[R5,#0x00000001]! 		
NOP				
	......	
	......}    X 128 total
	......
LDRB R7,[R6,#0x00000002]		
STRB R7,[R5,#0x00000001]!		 
NOP	
LDRB R7,[R6,#0x00000002]		
STRB R7,[R5,#0x00000001]!
NOP

As you can see, it doesn't branch anywhere. The problem is:

ON THE KEIL ARM SIMULATOR (60 MHZ) THE ROUTINE SAMPLES AT 10 Mhz.

ON THE REAL CHIP (60 MHZ) THE ROUTINE SAMPLES AT 5,5 Mhz ! ( I 
specify the function to be copied to ram)	

Meanwhile, I use an output compare timer on a pin, and it works at 
10 Mhz both on the simulator and the chip (checked on a scope)!

The simulator shows the lDRB, STRB need 2,3 and the nop 1 cycle, 
hence rate = 60 / (3+2+1) = 10Mhz

I guess LDRB, STRB actually take double time. If it is so, does 
anybody know why? Is there any way around this?

I tried using four temporary registers in a chain sequence in case 
of a pipeline issue from sequentially accessing the same register, 
and stoped using write back. The result was the same. When I took 
the NOP's out, speed was increased by approx. 1/10th.

Unfortunately I must use the 2138, and it has no external bus. Is it 
possible to achieve 10 Mhz sampling with this chip?

Thank you.

Re: Different execution speed between simulator and chip (LDRB, STRB instructions).

2005-09-26 by Karl Olsen

--- In lpc2000@yahoogroups.com, "conhalk" <conhalk@y...> wrote:

> I am using the lpc2138, and I have wrote a program which includes 
> reading port0.16-24 pins at a 10 Mhz sampling rate:

[...]

> ON THE KEIL ARM SIMULATOR (60 MHZ) THE ROUTINE SAMPLES AT 10 Mhz.
> 
> ON THE REAL CHIP (60 MHZ) THE ROUTINE SAMPLES AT 5,5 Mhz ! ( I 
> specify the function to be copied to ram)	
> 
> Meanwhile, I use an output compare timer on a pin, and it works at 
> 10 Mhz both on the simulator and the chip (checked on a scope)!
> 
> The simulator shows the lDRB, STRB need 2,3 and the nop 1 cycle, 
> hence rate = 60 / (3+2+1) = 10Mhz
> 
> I guess LDRB, STRB actually take double time. If it is so, does 
> anybody know why? Is there any way around this?

The Keil simulator doesn't know about the waitstates that the MAM and 
AHB-to-VPB bridge add.  The simulator is not useful for simulating 
the timing of code involving jumps in flash and loads/stores to VPB 
peripherals.

See also http://groups.yahoo.com/group/lpc2000/message/7808

> Unfortunately I must use the 2138, and it has no external bus. Is
> it possible to achieve 10 Mhz sampling with this chip?

I don't think so.  It would with the new LPC214x or LPC210{1,2,3}.

Karl Olsen

Re: Different execution speed between simulator and chip (LDRB, STRB instructions).

2005-09-27 by conhalk

Thank you Karl. I guess I will have to use a latch externally and 
read two bytes each time on P0.0-16. Anyway, I believe the simulator 
shouldn't display those waveforms and timing information, since 
letting you select a specific chip as target, and simulating its 
peripherals implies they have sorted these things out.



--- In lpc2000@yahoogroups.com, "Karl Olsen" <kro@p...> wrote:
> --- In lpc2000@yahoogroups.com, "conhalk" <conhalk@y...> wrote:
> 
> > I am using the lpc2138, and I have wrote a program which 
includes 
> > reading port0.16-24 pins at a 10 Mhz sampling rate:
> 
> [...]
> 
> > ON THE KEIL ARM SIMULATOR (60 MHZ) THE ROUTINE SAMPLES AT 10 Mhz.
> > 
> > ON THE REAL CHIP (60 MHZ) THE ROUTINE SAMPLES AT 5,5 Mhz ! ( I 
> > specify the function to be copied to ram)	
> > 
> > Meanwhile, I use an output compare timer on a pin, and it works 
at 
> > 10 Mhz both on the simulator and the chip (checked on a scope)!
> > 
> > The simulator shows the lDRB, STRB need 2,3 and the nop 1 cycle, 
> > hence rate = 60 / (3+2+1) = 10Mhz
> > 
> > I guess LDRB, STRB actually take double time. If it is so, does 
> > anybody know why? Is there any way around this?
> 
> The Keil simulator doesn't know about the waitstates that the MAM 
and 
> AHB-to-VPB bridge add.  The simulator is not useful for simulating 
> the timing of code involving jumps in flash and loads/stores to 
VPB 
Show quoted textHide quoted text
> peripherals.
> 
> See also http://groups.yahoo.com/group/lpc2000/message/7808
> 
> > Unfortunately I must use the 2138, and it has no external bus. Is
> > it possible to achieve 10 Mhz sampling with this chip?
> 
> I don't think so.  It would with the new LPC214x or LPC210{1,2,3}.
> 
> Karl Olsen

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.