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.

CCS/TMS320F28335: Unable to open/read a .csv file

Part Number: TMS320F28335

Tool/software: Code Composer Studio

Hello,

I am having difficulty figuring out why fopen does not allow me to open the file. When I debug it won't reach the if statement and currently doesn't let me set a breakpoint at the fopen line. I tested my code in MVS and it works fine.

I only get two warnings:

#10247-D null: creating output section ".cio" without a SECTIONS specification Test    C/C++ Problem
#10247-D null: creating output section "ramfuncs" without a SECTIONS specification Test    C/C++ Problem

#include "DSP28x_Project.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void main(void)
{
    DisableDog();
    FILE *outfile = fopen("test.csv", "r");
    if (outfile != NULL) {
        exit(1);
    }
    char data[52][100];
    fgets(data[0], 100, outfile);
    fclose(outfile);

}

Thanks in advance,

Jose

  • These warnings ...

    Jose De Casas said:
    #10247-D null: creating output section ".cio" without a SECTIONS specification Test    C/C++ Problem
    #10247-D null: creating output section "ramfuncs" without a SECTIONS specification Test    C/C++ Problem

    ... indicate you are not using the correct linker command file.  As a workaround, add entries to the linker command file to put each of these output sections in a range of memory that can be both read and written.  To understand more about why your linker command file is lacking, please start a new thread in the C2000 device forum.  Or, if you prefer, I can move this thread to that forum.

    That may not be your only problem.  Please see the article Tips for Using Printf for more background and suggestions.

    Thanks and regards,

    -George

  • I am currently using the 28335_RAM_lnk.cmd file. I am pretty new to all this, so how exactly would I add an entry like you have stated?

    As for the tips, I changed the heap size to 0x100 and stack size to 0x300, but like I said before, I am unsure if this was the correct thing to do. I wasn't sure what was the proper way to set a correct size. In addition, I also put the optimization level to "Whole Program Optimizations".

    I think I figured out how to add the entries: 

    SECTIONS
    {
       /* Setup for "boot to SARAM" mode:
          The codestart section (found in DSP28_CodeStartBranch.asm)
          re-directs execution to the start of user code.  */
       codestart        : > BEGIN,     PAGE = 0
       
    #ifdef __TI_COMPILER_VERSION__
       #if __TI_COMPILER_VERSION__ >= 15009000
        .TI.ramfunc : {} > RAML0,      PAGE = 0
       #else
       ramfuncs         : > RAML0,     PAGE = 0   
       #endif
    #endif    
       
       .text            : > RAML1,     PAGE = 0
       .cinit           : > RAML0,     PAGE = 0
       .pinit           : > RAML0,     PAGE = 0
       .switch          : > RAML0,     PAGE = 0
       .cio		    : > RAML0,	   PAGE = 0 //I added this line
       ramfuncs	    : > RAML0,	   PAGE = 0 //I added this line
    
       .stack           : > RAMM1,     PAGE = 1
       .ebss            : > RAML4,     PAGE = 1
       .econst          : > RAML5,     PAGE = 1
       .esysmem         : > RAMM1,     PAGE = 1
    
       IQmath           : > RAML1,     PAGE = 0
       IQmathTables     : > IQTABLES,  PAGE = 0, TYPE = NOLOAD

    It made the warnings go away, but the same issue as before.

    Thanks for your help,

    Jose

  • Another thing I noticed, was that if I comment out the fgets function, the file is able to open with no error.

    Also, when I step into fopen, I reach this:

    ***********************************************************************
    * Function: codestart section
    *
    * Description: Branch to code starting point
    ***********************************************************************
    
        .sect "codestart"
    
    code_start:
        .if WD_DISABLE == 1
            LB wd_disable       ;Branch to watchdog disable code //this line of code. And it loops from here and back to fopen.
        .else
            LB _c_int00         ;Branch to start of boot.asm in RTS library
        .endif

  • I just noticed this line in the main function ...

    Jose De Casas said:
    char data[52][100];

    That line alone takes up 5200 words of stack.  This means you overflow the stack by a lot.  Make that a global variable. Then your program probably won't link, and you will have to make that array smaller.

    If that doesn't fix the problem, I suggest you simplify your program a lot.  Try getting this program to work ...

    #include <stdio.h>
    int main() { puts("Hello, world!"); }

    Thanks and regards,

    -George