This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Memory access in a loop


You could try the following to see if it makes any difference:

#include <cyg/hal/hal_arch.h>

for(int i=0; i<10; i++)
{
  x[i] =  *(volatile unsigned short *)(0x200b8f6);
  HAL_REORDER_BARRIER();
}

You could also try compiling with the -S flag and inspect the resulting
assembler code to see what's going on (or disassemble using GDB or objdump).

Also, be aware of the cache in the S3C4510 - it looks like it's enabled by
default (see hal_hardware_init() in  e7t_misc.c). Single stepping and
debugging may affect the way it works. You may need to put an explicit cache
flush in after each read (using 'volatile' does NOT mean that it won't be
cached) - try the following to see if it makes any difference:

#include <cyg/hal/hal_cache.h>

for(int i=0; i<10; i++)
{
  x[i] =  *(volatile unsigned short *)(0x200b8f6);
  HAL_DCACHE_INVALIDATE_ALL();
}

As for the query about the logic analyser, it's difficult to answer this as
it doesn't appear to be related to eCos and there is no information on the
logic analyser anyway.

Robert Cragie, Design Engineer

Direct: +44 (0) 114 281 4512
_______________________________________________________________
Jennic Ltd, Furnival Street, Sheffield, S1 4QT,  UK
http://www.jennic.com  Tel: +44 (0) 114 281 2655
_______________________________________________________________
Visit our stand at Electronica, Munich 12-14 November 2002
_______________________________________________________________



> -----Original Message-----
> From: ecos-discuss-owner@sources.redhat.com
> [mailto:ecos-discuss-owner@sources.redhat.com]On Behalf Of peter_ku
> Sent: 10 October 2002 05:36
> To: 'Ecos-Discuss'
> Subject: RE: [ECOS] Memory access in a loop
>
>
> I made some mistake, and confuse you.sorry for that and  thank
> you for correction.
>
> Hi,
>
> I use GCC 2.95.2 / insight5.1 , target is E7T.
>
> I want to access memory in a loop
>
> unsigned  short x[10];
> for(int i=0; i<10; i++)
> {
>   x[i] =  *(volatile unsigned short *)(0x200b8f6);
> }
>
> the address 0x200b8f6 is a entry point for another memory pool,
> after I read it once, the memory pointer will increase automatically.
> I found a problem.
> 1. If I didn't set any breakpoint , it will only access the
> memory once. it means x[0] and x[1]........[10] are all the same value.
>     I use the Logic Analyzer to make sure this
>
> 2. If I set a breakpoint or debug step by step, it will access
> the memory ten times. it is more normal.
>
> any one can help me?
> PS:  I have already turn off the optimize -O0.
>
> One more question:
>
> When I use Logic Analyzer,  I want to "read" *(volatile unsigned
> short *)(0x200b8f6)
> I found it will read from 0x200b8f8, 0x200b8fa, 0x200b8fc,
> 0x200b8fe , 0x200b8f0, 0x200b8f2 , 0x200b8f4, and the last one is
> 0x200b8f6(this is what I want)
>
> PS : "write" will not cause this problem
>
>
> Best Regards,
> Peter


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]