TODOPIC

Microcontroladores PIC => Pic32 => Mensaje iniciado por: KALLITOS en 06 de Marzo de 2012, 20:28:20

Título: problemas con sprintf + FSIO
Publicado por: KALLITOS en 06 de Marzo de 2012, 20:28:20
Hola amigos, estoy jugando con el starter kit ethernet, probando codigo de mchp, en sí es PIC32 ESK usb host - mass storage simple demo que se encuentra en la web de mchp.

El ejemplo inicialmente compila bien, genera un archivo de texto en un pendrive, hasta alli todo bien.
Cambié la extensión del archivo y le puse .xls y compila bien y graba, la cosa es cuando uso la funcion sprintf no me deja manipular las variables a mi antojo, les dejo codigo que estoy usando:

Código que funciona correctamente:
Código: C
  1. if(FSInit())
  2.             {
  3.                 //Opening a file in mode "w" will create the file if it doesn't
  4.                 //  exist.  If the file does exist it will delete the old file
  5.                 //  and create a new one that is blank.
  6.                 myFile = FSfopen("T09-11.XLS","w");
  7.  
  8.                 //Write some data to the new file.
  9.                 FSfwrite("PRUEBA DE CONTEO\r",1,17,myFile);
  10.  
  11.                                 for(cont_x = 0;cont_x<10;cont_x++)
  12.                                         {
  13.                                         sprintf(my_string,"CONT_X: \t");
  14.                                         FSfwrite(my_string,1,30,myFile);
  15.                                         for(cont_y = 0;cont_y<25;cont_y++)
  16.                                                 {
  17.                                                 sprintf(my_string,"CONT_Y\t");
  18.                                                 FSfwrite(my_string,1,30,myFile);
  19.                                                 }
  20.  
  21.                         FSfwrite("\r",1,1,myFile);
  22.                                         }
  23.                 //Always make sure to close the file so that the data gets
  24.                 //  written to the drive.
  25.                 FSfclose(myFile);
  26.  
  27.                 //Just sit here until the device is removed.
  28.                 while(deviceAttached == TRUE)
  29.                 {
  30.                     USBTasks();
  31.                 }
  32.             }

Este código funciona bien, hace lo ke se espera, el problema viene cuando hago esto

Código: C
  1. sprintf(my_string,"CONT_X: %u\t",cont_x);

me marca este error:
`_mon_write' referenced in section `.text.write' of c:/program files/microchip/mplabc32/v2.02/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/lib\libc.a(write.o): defined in discarded section `.discard' of Objects - PIC32 Ethernet Starter Kit\main.o
`_mon_write' referenced in section `.text.write' of c:/program files/microchip/mplabc32/v2.02/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/lib\libc.a(write.o): defined in discarded section `.discard' of Objects - PIC32 Ethernet Starter Kit\main.o
`_mon_write' referenced in section `.text.write' of c:/program files/microchip/mplabc32/v2.02/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/lib\libc.a(write.o): defined in discarded section `.discard' of Objects - PIC32 Ethernet Starter Kit\main.o
`_mon_putc' referenced in section `.text.write' of c:/program files/microchip/mplabc32/v2.02/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/lib\libc.a(write.o): defined in discarded section `.discard' of Objects - PIC32 Ethernet Starter Kit\main.o
collect2: ld returned 1 exit status
Link step failed.


En cabecera esta el <stdio.h>

No se como solucionarlo, alguien sabe como hacer que corra normal??.



Saludos
Título: Re: problemas con sprintf + FSIO
Publicado por: KALLITOS en 07 de Marzo de 2012, 19:22:16
Hola, al parecer la manera de organizar los archivos que tiene mchp influye en el momento de la compilada, el ejemplo que estaba usando lo descargue desde la web de mchp; busque en la carpeta de Microchip Solutions y esa si corre bien.

Sigo jugando con esto.

Saludos.