MCF52259 Demo Board Userram Issue.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCF52259 Demo Board Userram Issue.

Jump to solution
2,965 Views
FWFan
Contributor III

Hi All,

 

I am running into user ram problem as I try to increase my array size to 256 elements of 16 bits.  It works at 254, but as soon as I tried 256 the program runs once and freezes.  I changed the userram size in the Internal Ram cfg from 0x1800 to 0x200A but this does not solve the problem.  I haven't look into the data sheet deeply yet.  I was wondering if you guys may have an answer to this issue before already.

 

I have looked in the forum for help but haven't really found an answer yet.  Your help is much appreciated.

 

Thank you in advance.

FWFan

Labels (1)
0 Kudos
Reply
1 Solution
1,508 Views
FWFan
Contributor III

Hi Ipa,

 

After re-reading this post, it is very helpful.  I can see now how I can process a set of data and not loose the next set of data.  By the way, I found the bug in my adc problem.  Another function was declaring the array index to be uint8 instead of uint16.  This is why my program freezes at 255 or greater.  Thank you very much for your help so far.

 

FWFan

View solution in original post

0 Kudos
Reply
9 Replies
1,508 Views
ipa
Contributor III

Hi,

Can you tell us what file did you changed for your 'useram'? Both linker file and 52259.mem should be untouched (0xFFFF=64K ram)- you can have used more ram than declared and then trouble. Check your .map file.

Regards,

ipa

0 Kudos
Reply
1,508 Views
FWFan
Contributor III

Hi ipa,

 

I changed the M52259DEMO_INTERNAL_RAM.lcf file, is this the linker file?  If so, is there a way for me to increase the ram I needed? 

 

Thank you for your help.

FWFan

 

# Sample Linker Command File for CodeWarrior for ColdFire

KEEP_SECTION {.vectortable}

# Memory ranges 

MEMORY {
   vectorram   (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000500
   code        (RX)  : ORIGIN = 0x20000500, LENGTH = 0x00004B00
   userram     (RWX) : ORIGIN = 0x20005000, LENGTH = 0x0000200A
}

SECTIONS {
 
# Heap and Stack sizes definition
 ___heap_size   = 0x400;
 ___stack_size     = 0x800;

 

# MCF52259 Derivative Memory map definitions from linker command files:
# __IPSBAR, __RAMBAR, __RAMBAR_SIZE, __FLASHBAR, __FLASHBAR_SIZE linker
# symbols must be defined in the linker command file.

# Memory Mapped Registers (IPSBAR= 0x40000000)
   ___IPSBAR         = 0x40000000;

# 32 Kbytes Internal SRAM
   ___RAMBAR         = 0x20000000;
   ___RAMBAR_SIZE    = 0x0000FFFF;

# 512 KByte Internal Flash Memory
   ___FLASHBAR       = 0x00000000;
   ___FLASHBAR_SIZE  = 0x00080000;

   ___SP_AFTER_RESET = ___RAMBAR + ___RAMBAR_SIZE - 4;
  
  .userram   : {} > userram  
  .code     : {} > code  
  .vectorram : {} > vectorram   
 
 .vectors :
 {
  exceptions.c(.vectortable)
  . = ALIGN (0x4);
 } >> code


 .text :
 {
  *(.text)
  . = ALIGN (0x4);
  *(.rodata)
  . = ALIGN (0x4);  
  ___ROM_AT = .;
  ___DATA_ROM = .;
 } >> code

 .data : AT(___ROM_AT)
 { 
  ___DATA_RAM = .;
  . = ALIGN(0x4);
  *(.exception) 
  . = ALIGN(0x4); 
  __exception_table_start__ = .;
  EXCEPTION
  __exception_table_end__ = .;
  
  ___sinit__ = .;
     STATICINIT
  __START_DATA = .;

  *(.data)
  . = ALIGN (0x4);
  __END_DATA = .;

  __START_SDATA = .;
  *(.sdata)
  . = ALIGN (0x4);
  __END_SDATA = .;

  ___DATA_END = .;
  __SDA_BASE = .;
  . = ALIGN (0x4);
 } >> userram

 .bss :
 {
  ___BSS_START = .;
  __START_SBSS = .;
  *(.sbss)
  . = ALIGN (0x4);
  *(SCOMMON)
  __END_SBSS = .;

  __START_BSS = .;
  *(.bss)
  . = ALIGN (0x4);
  *(COMMON)
  __END_BSS = .;
  ___BSS_END = .;

  . = ALIGN(0x4);
 } >> userram

 .custom :
 {
  ___HEAP_START = .;
  ___heap_addr = ___HEAP_START;
  ___HEAP_END  = ___HEAP_START + ___heap_size;
  ___SP_END  = ___HEAP_END;
  ___SP_INIT  = ___SP_END + ___stack_size;

  . = ALIGN (0x4);
 } >> userram
   
 ___VECTOR_RAM  = ADDR(.vectorram);
 
 __SP_INIT  = ___SP_INIT;

 _romp_at = ___ROM_AT + SIZEOF(.data);
 .romp : AT(_romp_at)
 {
  __S_romp = _romp_at;
  WRITEW(___ROM_AT);
  WRITEW(ADDR(.data));
  WRITEW(SIZEOF(.data));
  WRITEW(0);
  WRITEW(0);
  WRITEW(0);
 }

}

0 Kudos
Reply
1,508 Views
ipa
Contributor III

Hi,

I have read your code and linker file.

First, in linker file you can increase the size of userram section, but with care. Check first the .map file and see if needed. If you do not use malloc routines, the amount of userram size can be quite high, limited by the stack. 

But I think the problem is in other place: in your code, you set the ADC to generate interrupt and then you hunt the interrupt flag to aquire the data in *adcArryPtr(). This should be done into an interrupt routine in this case, not in a function returning a pointer. You must declare your interrupt routine as:

__interrupt__ adc_completion(void){

..

}

and place this name into vectors section and init the interrupt controller; in this interrupt routine

you must clear the interrupt flag and then eventually re-start the adc and get out of the routine; after aquisition of needed number of samples it is wise to transfer the data to another buffer; this gives you the time to process the data while aquiring anoter set of results.

Regards,

ipa 

0 Kudos
Reply
1,509 Views
FWFan
Contributor III

Hi Ipa,

 

After re-reading this post, it is very helpful.  I can see now how I can process a set of data and not loose the next set of data.  By the way, I found the bug in my adc problem.  Another function was declaring the array index to be uint8 instead of uint16.  This is why my program freezes at 255 or greater.  Thank you very much for your help so far.

 

FWFan

0 Kudos
Reply
1,508 Views
FWFan
Contributor III

Thank you Ipa,

 

I will give ISR a try.  I wanted to avoid ISR because it's so hard to do with 32-bit than with 8-bit.  In the 8-bit IDE, I can get the available isr vector easily, but in 32-bit IDE, I don't think it's quite as easy.  In any case, let me give this a try and I'll let you know if I have solve this userram and isr problems.

 

Thank you again,

FWFan

0 Kudos
Reply
1,508 Views
scifi
Senior Contributor I
My guess is that the bug is related to the way you use this array. You could have some 8-bit index arithmetics that overflows as soon as you increase array size to 256. Or it could be something else entirely: it's impossible to be sure based on your problem description.
0 Kudos
Reply
1,508 Views
FWFan
Contributor III

Hi scifi,

 

You are right.  My adc function uses uint16, but another function that uses the adc samples was using uint8.  That is why the program freezes at 255 or greater.  Thank you very much for your help.  Sorry about that.

 

FWFan

0 Kudos
Reply
1,508 Views
FWFan
Contributor III

Hi scifi,

 

I checked and my index is uint16.   It must be something else.  I was getting the userram error when I linked before I increase the userram size.  I don't know if this is the thing to do or not.   Please take a look at my attachment.  I am unfamiliar with this area.

 

Thank you for your help.

FWFan

0 Kudos
Reply
1,508 Views
FWFan
Contributor III

Oops, here is the .lcf file where I changed the usseram.

 

# Sample Linker Command File for CodeWarrior for ColdFire

KEEP_SECTION {.vectortable}

# Memory ranges 

MEMORY {
   vectorram   (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000500
   code        (RX)  : ORIGIN = 0x20000500, LENGTH = 0x00004B00
   userram     (RWX) : ORIGIN = 0x20005000, LENGTH = 0x0000200A
}

SECTIONS {
 
# Heap and Stack sizes definition
 ___heap_size   = 0x400;
 ___stack_size     = 0x800;

 

# MCF52259 Derivative Memory map definitions from linker command files:
# __IPSBAR, __RAMBAR, __RAMBAR_SIZE, __FLASHBAR, __FLASHBAR_SIZE linker
# symbols must be defined in the linker command file.

# Memory Mapped Registers (IPSBAR= 0x40000000)
   ___IPSBAR         = 0x40000000;

# 32 Kbytes Internal SRAM
   ___RAMBAR         = 0x20000000;
   ___RAMBAR_SIZE    = 0x0000FFFF;

# 512 KByte Internal Flash Memory
   ___FLASHBAR       = 0x00000000;
   ___FLASHBAR_SIZE  = 0x00080000;

   ___SP_AFTER_RESET = ___RAMBAR + ___RAMBAR_SIZE - 4;
  
  .userram   : {} > userram  
  .code     : {} > code  
  .vectorram : {} > vectorram   
 
 .vectors :
 {
  exceptions.c(.vectortable)
  . = ALIGN (0x4);
 } >> code


 .text :
 {
  *(.text)
  . = ALIGN (0x4);
  *(.rodata)
  . = ALIGN (0x4);  
  ___ROM_AT = .;
  ___DATA_ROM = .;
 } >> code

 .data : AT(___ROM_AT)
 { 
  ___DATA_RAM = .;
  . = ALIGN(0x4);
  *(.exception) 
  . = ALIGN(0x4); 
  __exception_table_start__ = .;
  EXCEPTION
  __exception_table_end__ = .;
  
  ___sinit__ = .;
     STATICINIT
  __START_DATA = .;

  *(.data)
  . = ALIGN (0x4);
  __END_DATA = .;

  __START_SDATA = .;
  *(.sdata)
  . = ALIGN (0x4);
  __END_SDATA = .;

  ___DATA_END = .;
  __SDA_BASE = .;
  . = ALIGN (0x4);
 } >> userram

 .bss :
 {
  ___BSS_START = .;
  __START_SBSS = .;
  *(.sbss)
  . = ALIGN (0x4);
  *(SCOMMON)
  __END_SBSS = .;

  __START_BSS = .;
  *(.bss)
  . = ALIGN (0x4);
  *(COMMON)
  __END_BSS = .;
  ___BSS_END = .;

  . = ALIGN(0x4);
 } >> userram

 .custom :
 {
  ___HEAP_START = .;
  ___heap_addr = ___HEAP_START;
  ___HEAP_END  = ___HEAP_START + ___heap_size;
  ___SP_END  = ___HEAP_END;
  ___SP_INIT  = ___SP_END + ___stack_size;

  . = ALIGN (0x4);
 } >> userram
   
 ___VECTOR_RAM  = ADDR(.vectorram);
 
 __SP_INIT  = ___SP_INIT;

 _romp_at = ___ROM_AT + SIZEOF(.data);
 .romp : AT(_romp_at)
 {
  __S_romp = _romp_at;
  WRITEW(___ROM_AT);
  WRITEW(ADDR(.data));
  WRITEW(SIZEOF(.data));
  WRITEW(0);
  WRITEW(0);
  WRITEW(0);
 }

}

0 Kudos
Reply