This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Stack and code in different pages...not working?

Other Parts Discussed in Thread: TMS320F28335

Hi,

TMS320F28335, CCS3.3, code generation tools 5.2.4. Using floating point support.

This might be something really basic but my code does not work if I link the stack to page 0, RAMM0 and then the code to page 1 (.text to RAML4-7). A function is called with parameters on stack. OK, works. Now inside this function, I call sscanf() with this same function:

void VAT3_f_switch(char* Parameters)                                                       
{                                                                                          
     int freq_temp;                                                                           
     float temp1;                                                                              
     int ParamCount=0; 
     char msg[6];                                                                        
                                                                                             
     ParamCount=sscanf(Parameters,"%d",&freq_temp);

I can see the "Parameters" got OK so far, inside the VAT3_f_switch(), but the sscanf does not work with the "Parameters". This does not occur if I link the stack to page 1 also, or the .text to page 0 together with the stack.

I must keep the .text in the page 1. The whereabouts of .stack is irrelevant to me. But the idea that I can't link senctions and stack where ever I want drives me crazy.

What am I doing wrong?

Thanks in advance,

Jormaporo

  • Jormaporo said:

    Hi,

    TMS320F28335, CCS3.3, code generation tools 5.2.4. Using floating point support.

    This might be something really basic but my code does not work if I link the stack to page 0, RAMM0 and then the code to page 1 (.text to RAML4-7). A function is called with parameters on stack. OK, works. Now inside this function, I call sscanf() with this same function:

    void VAT3_f_switch(char* Parameters)                                                       
    {                                                                                          
         int freq_temp;                                                                           
         float temp1;                                                                              
         int ParamCount=0; 
         char msg[6];                                                                        
                                                                                                 
         ParamCount=sscanf(Parameters,"%d",&freq_temp);

    I can see the "Parameters" got OK so far, inside the VAT3_f_switch(), but the sscanf does not work with the "Parameters". This does not occur if I link the stack to page 1 also, or the .text to page 0 together with the stack.

    I must keep the .text in the page 1. The whereabouts of .stack is irrelevant to me. But the idea that I can't link senctions and stack where ever I want drives me crazy.

    What am I doing wrong?

    Thanks in advance,

    Jormaporo

    Jormapro,

    My feeling is in the configuration that does not work, something is growing too large and overwriting something else.  The suspects are usually stack or heap.  If I recall, scanf takes a large chunk of heap memory.  Can you try increasing your heap?

    You can try filling the memory with a known value using the CCS menus before you execute the code.  Then you will be able to tell what memory has been used and if it is growing too large.

    This wiki might help: http://processors.wiki.ti.com/index.php/Tips_for_using_printf

    Also on the page 0 / page 1 - typically code is on page 0 and data on page 1.  But on 28x keep in mind all the memory is uniformly mapped in both program and data space.  What is important is the memory block that you map to and that there is not an overlapping memory defined on the other page.  For example, if your stack starts at address 0x0000 on page 1, you should not have any program at 0x0000 on page 0.  The memory at 0x0000 is physically the same.

    Another thing I suggest is using the -w linker option.  This will warn you if the compiler is assigning any sections to memory without your input.  In other words the compiler sees a section and memory where it will fit, but you did not tell it explicitly in the linker file to put the section into that memory.  This can help debug memory conflicts.

    This wiki may be useful:

    http://processors.wiki.ti.com/index.php/C28x_Code_Generation_Tips_and_Tricks

    http://processors.wiki.ti.com/index.php/C28x_Compiler_-_Understanding_Linking

    Regards,

    -Lori