DSPRelated.com
Forums

'C32 memory access problem

Started by m_zapateiro June 11, 2005
Hi all!

I've been having trouble accesing the different memory banks of
the 'C32. I have a 32 bit ROM (256k) connected to STRB0, a 32 bit RAM
(32k) connected to IOSTRB and an 8 bit microcontroller parallel port is
connected to STRB1.

I have allocated the .bss section in the external RAM as well
as .sysmem section. The parallel port is accesed by means of mallo8()
function, so .sysm8 is allocated in STRB1.

When I run the program, I get unexpected results. For example, the DSP
never writes to the memory location at 0x900000 (where the
microcontroller is mapped), some functions are never executed, for
example, a single for loop is never run though the code before and
after this is.

I've been compiling under the small memory model. Is it possible under
these circumstances to do it? Or is it necessary to compile under the
big mememory model?

These are the options I'm using when compiling and linking:
mk30 --c --h --k -o rts.src -l rts32.lib
cl30 -v32 -ss -o test.c
asm30 -v32 Isr_vecs_funciona.asm (my interrupt vector)
lnk30 mymem.cmd

Can anyone see any mistake or something missing? Thanks for your help!

P.S.:
This is my memory map:

-c Isr_vecs_funciona.obj test.obj
-stack 0x100
-heap 0x0
-heap8 0x1
-m memory_ent
-l rts32.lib
-o out_funciona.out

MEMORY
{
VECT (RX): org = 0x0 len = 0x40
EXT0 (RX): org = 0x40 len = 0x3FFC0
EXT1 (RW): org = 0x810000 len = 0x4000
RAM0 (RW): org = 0x87FE00 len = 0x100
RAM1 (RW): org = 0x87FF00 len = 0x100
PIC_M (RW): org = 0x900000 len = 0x1
}

SECTIONS
{
vectores:> VECT
.cinit: > EXT0
.const: > EXT0
.data: > EXT0
.text: > EXT0
.stack: > RAM0
.bss: > EXT1
.sysm8: > PIC_M
.sysmem: > EXT1
}


Hello M_Zapateiro

I was pretty much a C4x, C31, VC33 programmer, so please dont expect too much in terms of what I know about the C31... Never the less I can remember a thing or two about the C32.  Ill see if I can come up with some ideas.

1) The first good sign is that you can (apparently) download and run code.
2) Have you rebuilt the RTS lib with the same attributes that you will be using in your final system?
3) If you assign a value to a global variable, will a simplified program properly access that value (maybe read and copy to another global)?
4) Will a simplified program, say looping with an global variable for the loop counter, execute properly?

If you are to this level (and I think you are), the next thing would be to consider how the C32 will allocate and use various memory types.  And, this is probably where things are going amiss.

Though the C32's external memory bus is capable of 8/16/32 bit access into a 8/16/32 physical memory width, the register that controls these accesses needs to be configured to the proper mode before the access is made.  Memory width is a constant (as defined by your system), but if you are mixing data types say 8b chars and and 32b floats from the same memory, you need to be sure these do not overlap.  If they do, you need to swap in bus control values each time an access is needed. 

You need to be aware that the intent of most C32 systems is to statically allocate a section of memory as say 8b chars to be used in a alphanumeric display, and then leave it that way for the duration of the application.  In theory the compiler would then not need to keep track and perform data type swapping.

Another thing I can think of is that you should probably wait a cycle or two after writing to a bus control register.  Basically the CPU pipeline and inevitable logic delay in the bus controller will take some cycles to become ready for the next data type access.  As you step into your code, you should see these values being written into the bus control registers.  These are probably the bread crumbs you need to be following!

Hope this helps
Best regards

Keith Larson
DSP and Analog Consultant
Lincoln Ma

k...@comcast.net
http://home.comcast.net/~klarsondsp/


m_zapateiro wrote:
Hi all!

I've been having trouble accesing the different memory banks of
the 'C32.  I have a 32 bit ROM (256k) connected to STRB0, a 32 bit RAM
(32k) connected to IOSTRB and an 8 bit microcontroller parallel port is
connected to STRB1.

I have allocated the .bss section in the external RAM as well
as .sysmem section.  The parallel port is accesed by means of mallo8()
function, so .sysm8 is allocated in STRB1.

When I run the program, I get unexpected results.  For example, the DSP
never writes to the memory location at 0x900000 (where the
microcontroller is mapped), some functions are never executed, for
example, a single for loop is never run though the code before and
after this is.

I've been compiling under the small memory model. Is it possible under
these circumstances to do it? Or is it necessary to compile under the
big mememory model?

These are the options I'm using when compiling and linking:
mk30 --c --h --k -o rts.src -l rts32.lib
cl30 -v32 -ss -o test.c
asm30 -v32 Isr_vecs_funciona.asm (my interrupt vector)
lnk30 mymem.cmd

Can anyone see any mistake or something missing? Thanks for your help!

P.S.:
This is my memory map:

-c Isr_vecs_funciona.obj test.obj                              
-stack 0x100
-heap  0x0                                         
-heap8 0x1                                               
-m memory_ent                                            
-l rts32.lib                                            
-o out_funciona.out                         

MEMORY
{
   VECT (RX):  org = 0x0      len = 0x40
   EXT0 (RX):  org = 0x40     len = 0x3FFC0 
   EXT1 (RW):  org = 0x810000 len = 0x4000  
   RAM0 (RW):  org = 0x87FE00 len = 0x100   
   RAM1 (RW):  org = 0x87FF00 len = 0x100   
   PIC_M (RW): org = 0x900000 len = 0x1
}

SECTIONS
{
    vectores:> VECT
   .cinit:  > EXT0
   .const:  > EXT0
   .data:   > EXT0
   .text:   > EXT0
   .stack:  > RAM0
   .bss:    > EXT1
   .sysm8: > PIC_M
   .sysmem: > EXT1  
}


NEW!  You can now post a message or access and search the archives of this group on DSPRelated.com:
http://www.dsprelated.com/groups/c3x/1.php

_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer.  You need to do a "reply all" if you want your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

Archives:  http://www.dsprelated.com/groups/c3x/1.php

To Post:  Send an email to c...@yahoogroups.com

Other DSP Related Groups: http://www.dsprelated.com/groups.php