Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

unable to use _sys_open() - keil uVision4 IDE

Status
Not open for further replies.

u2bpavankumar

Newbie level 6
Joined
Oct 21, 2009
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,380
Hi,

I am working on MCB2300 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
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top