This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

unable to use _sys_open()

Hi,

I am working on LPC2300 EVB. My requirement is to read data from a file and process it in the program. As we cannot use FILE I/O functions like fopen(), fclose() directly in IDE (Keil uVision4), I am making use of semihosting. Here is my code


#include <stdio.h>                /* prototype declarations for I/O functions */
#include <LPC23xx.H>              /* LPC23xx definitions                      */
#include <rt_sys.h>

/****************/
/* main program */
/****************/
int main (void)  {                /* execution starts here */

FILEHANDLE fp;


 long len;
 unsigned char* buf;
 int retval;


  /* initialize the serial interface   */
  PINSEL0 |= 0x40000000;        /* Enable TxD1 P0.15 */
  PINSEL1 |= 0x00000001;        /* Enable RxD1 P0.16 */
  U1LCR = 0x00000083;           /* 8 bits, no Parity, 1 Stop bit */
  U1DLL = 78;                   /* 9600 Baud Rate @ 12MHz VPB Clock */
  U1LCR = 0x00000003;           /* DLAB = 0 */

  while (1) {

     printf("In While Loop");

        fp = _sys_open("my.txt", OPEN_R) ;
        printf("FILE HANDLE value is %d \n", fp);

        len = _sys_flen(fp);
        printf("Length the current file is %d \n", len);

        retval=_sys_read(fp,buf,len,0);
        printf("Value returned is %d  \n", retval);


  }
}

This is my source code.

I also have included Serial.c and Retarget.c standard files in my project.

Here my intention is to see the FILEHANDLE value(fp), len, retval on serial window (UART2) when debugging.

Code gets compiled and during debugging I can only see the statement "In While Loop" printing continuously on serival window (UART2) and not getting any other values

Please help me how do i print the required values on the serial window

Thanks in advance

Regards,
Pavan

0